Line data Source code
1 : /* Copyright 1989-2025 Free Software Foundation, Inc. 2 : Written by James Clark (jjc@jclark.com) 3 : 4 : This file is part of groff, the GNU roff typesetting system. 5 : 6 : groff is free software; you can redistribute it and/or modify it under 7 : the terms of the GNU General Public License as published by the Free 8 : Software Foundation, either version 3 of the License, or 9 : (at your option) any later version. 10 : 11 : groff is distributed in the hope that it will be useful, but WITHOUT ANY 12 : WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 : FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 : for more details. 15 : 16 : You should have received a copy of the GNU General Public License 17 : along with this program. If not, see <http://www.gnu.org/licenses/>. */ 18 : 19 : #ifdef HAVE_CONFIG_H 20 : #include <config.h> 21 : #endif 22 : 23 : #include <ctype.h> 24 : 25 : #include "lib.h" 26 : 27 : #include "cset.h" 28 : #include "stringclass.h" 29 : #include "lf.h" 30 : 31 : extern void change_filename(const char *); 32 : extern void change_lineno(int); 33 : 34 48484 : bool interpret_lf_request_arguments(const char *p) 35 : { 36 48484 : while (*p == ' ') 37 24242 : p++; 38 24242 : if (!csdigit(*p)) 39 10 : return false; 40 24232 : int ln = 0; 41 60982 : do { 42 85214 : ln *= 10; 43 85214 : ln += *p++ - '0'; 44 85214 : } while (csdigit(*p)); 45 24232 : if (*p != ' ' && *p != '\n' && *p != '\0') 46 0 : return false; 47 26249 : while (*p == ' ') 48 2017 : p++; 49 24232 : if (*p == '\0' || *p == '\n') { 50 22215 : change_lineno(ln); 51 22215 : return true; 52 : } 53 : const char *q; 54 45356 : for (q = p; 55 45356 : *q != '\0' && *q != ' ' && *q != '\n' && *q != '\\'; 56 : q++) 57 : ; 58 4034 : string tem(p, q - p); 59 2017 : while (*q == ' ') 60 0 : q++; 61 2017 : if (*q != '\n' && *q != '\0') 62 0 : return false; 63 2017 : tem += '\0'; 64 2017 : change_filename(tem.contents()); 65 2017 : change_lineno(ln); 66 2017 : return true; 67 : } 68 : 69 : #if defined(__MSDOS__) || (defined(_WIN32) && !defined(__CYGWIN__)) 70 : void normalize_file_name_for_lf_request(string &fn) 71 : { 72 : int fnlen = fn.length(); 73 : for (int i = 0; i < fnlen; i++) { 74 : if (fn[i] == '\\') 75 : fn[i] = '/'; 76 : } 77 : } 78 : #else 79 1720 : void normalize_file_name_for_lf_request(string &) 80 : { 81 1720 : } 82 : #endif 83 : 84 : // Local Variables: 85 : // fill-column: 72 86 : // mode: C++ 87 : // End: 88 : // vim: set cindent noexpandtab shiftwidth=2 textwidth=72: