static int ReadTRSPass2(FILE *f, TRSData *TRSs) { rewind(f); GFFLineNr = 0; int TRSCount = 0; GFFRecord Rec; while (GetNextGFFRecord(f, Rec)) { if (0 != strcmp(Rec.Feature, "trs")) continue; if (Rec.Start <= 0 || Rec.End <= 0 || Rec.Start > Rec.End) Warning("GFF line %d: invalid start %d / end %d", GFFLineNr, Rec.Start, Rec.End); static char *Fam = GetFam(Rec); int FamIndex = 0; int SuperFamIndex = 0; int n = sscanf(Fam, "%d.%d", &FamIndex, &SuperFamIndex); if (n != 2) Quit("Invalid Family %s", Fam); TRSData &TRS = TRSs[TRSCount]; const int Length = Rec.End - Rec.Start + 1; TRS.ContigLabel = strsave(Rec.SeqName); TRS.ContigFrom = Rec.Start - 1; TRS.ContigTo = TRS.ContigFrom + Length - 1; TRS.FamIndex = FamIndex; TRS.SuperFamIndex = SuperFamIndex; if (Rec.Strand == '+') TRS.Rev = false; else if (Rec.Strand == '-') TRS.Rev = true; else Quit("GFF line %d, Invalid strand %c", GFFLineNr, Rec.Strand); ++TRSCount; } return TRSCount; }
// Search NAME along PATHP with the elements of PATHEXT in turn added. char *searchpathext(const char *name, const char *pathext, const char *pathp) { char *found = 0; char *tmpathext = strsave(pathext); // strtok modifies this string, // so make a copy char *ext = strtok(tmpathext, PATH_SEP); while (ext) { char *namex = new char[strlen(name) + strlen(ext) + 1]; strcpy(namex, name); strcat(namex, ext); found = searchpath(namex, pathp); a_delete namex; if (found) break; ext = strtok(0, PATH_SEP); } a_delete tmpathext; return found; }
/* * Extract Message-ID from ^AORIGID/^AORIGREF with special handling for * split messages (appended " i/n"). Returns NULL for invalid ^AORIGID. */ char *s_msgid_convert_origid(char *origid, int part_flag) { char *s, *p, *id, *part; TmpS *tmps; s = strsave(origid); id = s; part = NULL; p = strrchr(s, '>'); if(!p) { xfree(s); debug(1, "Invalid ^AORIGID: %s", origid); return NULL; } p++; if(is_space(*p)) { /* * Indication of splitted message " p/n" follows ... */ *p++ = 0; while(is_space(*p)) p++; part = p; } /* * Message-IDs must NOT contain white spaces */ if(strchr(id, ' ') || strchr(id, '\t')) { xfree(s); debug(1, "Invalid ^AORIGID: %s", origid); return NULL; } tmps = tmps_copy(id); xfree(s); return tmps->s; }
/* * Create new Regex struct for string */ static Regex *regex_parse_line(char *s) { Regex *p; int err; /* New regex entry */ p = regex_new(); p->re_s = strsave(s); err = regcomp(&p->re_c, p->re_s, REG_EXTENDED|REG_ICASE); if(err) { fglog("WARNING: error compiling regex %s", p->re_s); xfree(p); return NULL; } debug(15, "regex: pattern=%s", p->re_s); return p; }
/* * Create an empty VARIABLE. */ ETERM *erl_mk_var(const char *s) { ETERM *ep; if (!s) return NULL; /* ASSERT(s != NULL); */ ep = erl_alloc_eterm(ERL_VARIABLE); ERL_COUNT(ep) = 1; ERL_VAR_LEN(ep) = strlen(s); if ((ERL_VAR_NAME(ep) = strsave(s)) == NULL) { erl_free_term(ep); erl_errno = ENOMEM; return NULL; } ERL_VAR_VALUE(ep) = (ETERM *) NULL; return ep; }
static char* get_default_emulator(char* progname) { char sbuf[MAXPATHLEN]; char* s; if (strlen(progname) >= sizeof(sbuf)) return ERL_NAME; strcpy(sbuf, progname); for (s = sbuf+strlen(sbuf); s >= sbuf; s--) { if (IS_DIRSEP(*s)) { strcpy(s+1, ERL_NAME); if(file_exists(sbuf)) return strsave(sbuf); break; } } return ERL_NAME; }
void resource_manager::read_download_file() { char *path = 0; FILE *fp = font::open_file("download", &path); if (!fp) fatal("can't find `download'"); char buf[512]; int lineno = 0; while (fgets(buf, sizeof(buf), fp)) { lineno++; char *p = strtok(buf, " \t\r\n"); if (p == 0 || *p == '#') continue; char *q = strtok(0, " \t\r\n"); if (!q) fatal_with_file_and_line(path, lineno, "missing filename"); lookup_font(p)->filename = strsave(q); } a_delete path; fclose(fp); }
void include(void) { char name[100]; FILE *fin; int c; extern int errno; while ((c = input()) == ' ') ; unput(c); cstr(name, c == '"', sizeof(name)); /* gets it quoted or not */ if ((fin = fopen(name, "r")) == NULL) ERROR "can't open file %s", name FATAL; errno = 0; curfile++; curfile->fin = fin; curfile->fname = strsave(name); curfile->lineno = 0; printf(".lf 1 %s\n", curfile->fname); pushsrc(File, curfile->fname); }
// Strip the installation prefix and replace it // with the current installation prefix; return the relocated path. char *relocatep(const char *path) { #if DEBUG fprintf(stderr, "relocatep: path = %s\n", path); fprintf(stderr, "relocatep: INSTALLPATH = %s\n", INSTALLPATH); fprintf(stderr, "relocatep: INSTALLPATHLEN = %d\n", INSTALLPATHLEN); #endif if (!curr_prefix) set_current_prefix(); if (strncmp(INSTALLPATH, path, INSTALLPATHLEN)) return strsave(path); char *relative_path = (char *)path + INSTALLPATHLEN; size_t relative_path_len = strlen(relative_path); char *relocated_path = new char[curr_prefix_len + relative_path_len + 1]; strcpy(relocated_path, curr_prefix); strcat(relocated_path, relative_path); #if DEBUG fprintf(stderr, "relocated_path: %s\n", relocated_path); #endif /* DEBUG */ return relocated_path; }
static void AddHit(int PileIndex, const char *Label, int QueryFrom, int QueryTo, int TargetFrom, int TargetTo, bool Rev) { TouchPiles(PileIndex); TanPile &Pile = Piles[PileIndex]; if (0 == Pile.HitCount) { Pile.Label = strsave(Label); Pile.From = min(QueryFrom, TargetFrom); Pile.To = max(QueryTo, TargetTo); } else { if (0 != strcmp(Label, Pile.Label)) Quit("Labels disagree"); Pile.From = min3(Pile.From, QueryFrom, TargetFrom); Pile.To = max3(Pile.To, QueryTo, TargetTo); } ++(Pile.HitCount); }
/* * Extend the gl_pathv member of a glob_t structure to accomodate a new item, * add the new item, and update gl_pathc. * * This assumes the BSD realloc, which only copies the block when its size * crosses a power-of-two boundary; for v7 realloc, this would cause quadratic * behavior. * * Return 0 if new item added, error code if memory couldn't be allocated. * * Invariant of the glob_t structure: * Either gl_pathc is zero and gl_pathv is NULL; or gl_pathc > 0 and * gl_pathv points to (gl_offs + gl_pathc + 1) items. */ static void globextend(const char *path, glob_t *pglob) { char **pathv; int i; size_t newsize; newsize = sizeof(*pathv) * (2 + pglob->gl_pathc + pglob->gl_offs); pathv = xrealloc(pglob->gl_pathv, newsize); if (pglob->gl_pathv == NULL && pglob->gl_offs > 0) { /* first time around -- clear initial gl_offs items */ pathv += pglob->gl_offs; for (i = pglob->gl_offs; --i >= 0;) *--pathv = NULL; } pglob->gl_pathv = pathv; pathv[pglob->gl_offs + pglob->gl_pathc++] = strsave(path); pathv[pglob->gl_offs + pglob->gl_pathc] = NULL; }
char * get_set_var_name_int (char * s, int index, char * file, int line) { char var_buf [VAR_SIZE+1]; char fmt_buf [VAR_SIZE+1]; char * p; char * fmt; int index_found = 0; if (strlen (s) >= VAR_SIZE) { fatal_exit ("Variable name too long\n"); } for (p = fmt_buf, fmt=s; *fmt; fmt++) { *p++ = *fmt; if (*fmt == '%') { if (!index_found) { index_found = 1; *p++ = 'd'; } else { *p++ = '%'; } } } *p = '\0'; sprintf (var_buf, fmt_buf, index); if (strlen (var_buf) >= VAR_SIZE) { fatal_exit ("Variable name too long\n"); } return strsave (var_buf); }
/*============================================= * value_to_list -- Convert string to word list * str: [IN] input string to split up * list: [OUT] list of strings in name * plen: [OUT] #entries in list * dlm: [IN] delimiter upon which to split str *===========================================*/ LIST value_to_list (STRING str, INT *plen, STRING dlm) { static STRING buf = NULL; static INT len0 = 0; STRING p, q, n; INT len, c, i, j; LIST list = create_list2(LISTDOFREE); if (!str || *str == 0) return list; if ((len = strlen(str)) > len0 - 2) { if (buf) stdfree(buf); buf = (STRING) stdalloc(len0 = len + 80); } strcpy(buf, str); buf[len + 1] = 0; p = buf; j = 1; while ((c = *p++)) { if (in_string(c, dlm)) { *(p - 1) = 0; j++; } } p = buf; for (i = 1; i <= j; i++) { n = p + strlen(p) + 1; while (chartype(c = *p++) == WHITE) ; p--; q = p + strlen(p) - 1; while (q > p && chartype(*q) == WHITE) *q-- = 0; set_list_element(list, i, strsave(p), NULL); p = n; } *plen = j; return list; }
/*==================================+ * llrpt_addtoset -- Add person to INDISEQ * usage: addtoset(SET, INDI, ANY) -> VOID *=================================*/ PVALUE llrpt_addtoset (PNODE node, SYMTAB stab, BOOLEAN *eflg) { NODE indi=0; STRING key=0; INDISEQ seq=0; PNODE arg1 = builtin_args(node), arg2 = inext(arg1), arg3 = inext(arg2); PVALUE val1 = eval_and_coerce(PSET, arg1, stab, eflg); PVALUE val2=0; if (*eflg) { prog_var_error(node, stab, arg1, val1, nonsetx, "addtoset", "1"); return NULL; } ASSERT(seq = pvalue_to_seq(val1)); indi = eval_indi(arg2, stab, eflg, NULL); if (*eflg) { prog_var_error(node, stab, arg2, NULL, nonindx, "addtoset","2"); goto ats_exit; } if (!indi) goto ats_exit; *eflg = TRUE; if (!(key = strsave(rmvat(nxref(indi))))) { prog_error(node, "major error in addtoset."); goto ats_exit; } *eflg = FALSE; val2 = evaluate(arg3, stab, eflg); if (*eflg) { prog_error(node, "3rd arg to addtoset is in error."); goto ats_exit; } append_indiseq_pval(seq, key, NULL, val2, FALSE); ats_exit: if (key) strfree(&key); /* append made its own copy */ /* delay to last minute val1 cleanup lest it is a temp owning seq, eg, addtoset(ancestorset(i),j) */ if (val1) delete_pvalue(val1); return NULL; }
/* exists - if `name' readable return its path name or return null */ static char *exists(char *name) { List b; if ( (name[0] == '/' || name[0] == '\\' || name[2] == ':') && access(name, 4) == 0) return name; if (!(name[0] == '/' || name[0] == '\\' || name[2] == ':') && (b = lccinputs)) do { b = b->link; if (b->str[0]) { char buf[1024]; sprintf(buf, "%s/%s", b->str, name); if (access(buf, 4) == 0) return strsave(buf); } else if (access(name, 4) == 0) return name; } while (b != lccinputs); if (verbose > 1) return name; return 0; }
static void cgfrontInit( // INITIALIZE FOR FRONT-END CODE GENERATION INITFINI* defn ) // - definition { char seg_name[30]; // - computed segment name defn = defn; if( *TextSegName == '\0' ) { if( TargetSwitches & BIG_CODE ) { stpcpy( stpcpy( seg_name, ModuleName ), TS_SEG_CODE ); } else { stpcpy( seg_name, TS_SEG_CODE ); } CMemFreePtr( &TextSegName ); TextSegName = strsave( seg_name ); } SegmentInit( TextSegName ); codeCGFILE = NULL; dataCGFILE = CgioCreateFile( NULL ); emitDataCGFILE = &dataCGFILE; flags.init_data_beg = FALSE; flags.init_data_end = FALSE; }
static int ReadRepsPass2(FILE *f, RepData *Reps) { rewind(f); GFFLineNr = 0; int RepCount = 0; GFFRecord Rec; while (GetNextGFFRecord(f, Rec)) { if (0 != strcmp(Rec.Feature, "repeat")) continue; static char *Repeat = GetRepeat(Rec); RepData &Rep = Reps[RepCount]; ParseRepeat(Repeat, Rep); if (Rec.Start <= 0 || Rec.End <= 0 || Rec.Start > Rec.End) Warning("GFF line %d: invalid start %d / end %d", GFFLineNr, Rec.Start, Rec.End); const int Length = Rec.End - Rec.Start + 1; Rep.ContigLabel = strsave(Rec.SeqName); Rep.ContigFrom = Rec.Start - 1; Rep.ContigTo = Rep.ContigFrom + Length - 1; if (Rec.Strand == '+') Rep.Rev = false; else if (Rec.Strand == '-') Rep.Rev = true; else Quit("GFF line %d, Invalid strand %c", GFFLineNr, Rec.Strand); ++RepCount; } return RepCount; }
/*====================================+ * llrpt_inset -- See if person is in INDISEQ * usage: inset(SET, INDI) -> BOOL *==========================================*/ PVALUE llrpt_inset (PNODE node, SYMTAB stab, BOOLEAN *eflg) { NODE indi; STRING key=0; INDISEQ seq; BOOLEAN rel; PNODE arg1 = builtin_args(node), arg2 = inext(arg1); PVALUE val1 = eval_and_coerce(PSET, arg1, stab, eflg); PVALUE valr=0; if (*eflg ||!val1 || !(seq = pvalue_to_seq(val1))) { *eflg = TRUE; prog_var_error(node, stab, arg1, val1, nonsetx, "inset", "1"); goto inset_exit; } indi = eval_indi(arg2, stab, eflg, NULL); if (*eflg) { prog_var_error(node, stab, arg2, NULL, nonindx, "inset", "2"); goto inset_exit; } if (!indi) { rel = FALSE; } else { if (!(key = strsave(rmvat(nxref(indi))))) { *eflg = TRUE; prog_error(node, "major error in inset."); goto inset_exit; } rel = in_indiseq(seq, key); } valr = create_pvalue_from_bool(rel); inset_exit: /* delay delete of val1 to last minute lest it is a temp owning seq, eg, inset(ancestorset(i),j) */ if (val1) delete_pvalue(val1); if (key) strfree(&key); return valr; }
/*===================================== * check_indi -- check indi record * and record any records needing fixing * in tofix list *===================================*/ static BOOLEAN check_indi (CNSTRING key, RECORD rec) { static char prevkey[MAXKEYWIDTH+1]; CACHEEL icel1=0; RECORD recx=0; if (eqstr(key, prevkey)) { report_error(ERR_DUPINDI, _("Duplicate individual for %s"), key); } icel1 = indi_to_cacheel(rec); lock_cache(icel1); recx = get_record_for_cel(icel1); ASSERT(todo.pass == 1); process_indi(recx); unlock_cache(icel1); check_pointers(key, rec); append_indiseq_null(seq_indis, strsave(key), NULL, TRUE, TRUE); release_record(recx); return TRUE; }
/*===================================== * check_fam -- check family record * and record any records needing fixing * in tofix list *===================================*/ static BOOLEAN check_fam (CNSTRING key, RECORD rec) { static char prevkey[MAXKEYWIDTH+1]=""; CACHEEL fcel1=0; RECORD recx=0; if (eqstr(key, prevkey)) { report_error(ERR_DUPFAM, _("Duplicate family for %s"), key); } fcel1 = fam_to_cacheel(rec); lock_cache(fcel1); recx = get_record_for_cel(fcel1); ASSERT(todo.pass == 1); process_fam(recx); unlock_cache(fcel1); check_pointers(key, rec); append_indiseq_null(seq_fams, strsave(key), NULL, TRUE, TRUE); return TRUE; }
/* * add symbol to symbol table symtab, or modify existing symbol * * Input: sym_name pointer to string with symbol name * sym_val value of symbol * * Output: 0 symbol added/modified * 1 out of memory */ int put_sym(char *sym_name, int sym_val) { struct sym *get_sym(); register int hashval; register struct sym *np; char *strsave(char *); if (!gencode) return(0); if ((np = get_sym(sym_name)) == NULL) { np = (struct sym *) malloc(sizeof (struct sym)); if (np == NULL) return(1); if ((np->sym_name = strsave(sym_name)) == NULL) return(1); hashval = hash(sym_name); np->sym_next = symtab[hashval]; symtab[hashval] = np; } np->sym_val = sym_val; return(0); }
void do_definition(int is_simple) { int t = get_token(); if (t != TEXT) { lex_error("bad definition"); return; } token_buffer += '\0'; const char *name = token_buffer.contents(); definition *def = macro_table.lookup(name); if (def == 0) { def = new definition[1]; macro_table.define(name, def); } else if (def->is_macro) { a_delete def->contents; } get_delimited_text(); token_buffer += '\0'; def->is_macro = 1; def->contents = strsave(token_buffer.contents()); def->is_simple = is_simple; }
/*============================= * set_date_pic -- Set a custom ymd date picture * NULL or empty string will clear any existing custom pic * Created: 2001/12/30 (Perry Rapp) *===========================*/ void set_date_pic (STRING pic) { if (date_pic) { stdfree(date_pic); date_pic = 0; } if (pic && pic[0]) { STRING p; date_pic = strsave(pic); /* convert %y %m %d format to %1 %2 %3 */ for (p = date_pic; *p; ++p) { if (p[0]=='%') { if (p[1]=='y') p[1]='1'; else if (p[1]=='m') p[1]='2'; else if (p[1]=='d') p[1]='3'; } } } }
/*--------------------------------------------------------------- Routine : file_open_error Purpose : This routine is called if a file open error is detected. ---------------------------------------------------------------*/ static void file_open_error(fstruct *client_data, int called_from ) { char *error_message; error_message = strsave( client_data->file_error_string ); error_message = strgrow( error_message, filename_from_pathname( client_data->filename ) ); client_data->file_dialog_title = strgrow( client_data->file_dialog_title, "Open " ); client_data->file_dialog_title = strgrow( client_data->file_dialog_title, client_data->title ); printf("FileDialogs: file_open_error\n"); if(called_from == FD_FTA) { /* routine called from FTA code */ FTAFramePostError(error_message, client_data->file_dialog_title); } else if(called_from == FD_PED) { /* routine called from PED code */ PEDFramePostError(error_message, client_data->file_dialog_title); } } /* file_open_error */
void interpolate_macro_with_args(const char *body) { char *argv[9]; int argc = 0; int i; for (i = 0; i < 9; i++) argv[i] = 0; int level = 0; int c; do { token_buffer.clear(); for (;;) { c = get_char(); if (c == EOF) { lex_error("end of input while scanning macro arguments"); break; } if (level == 0 && (c == ',' || c == ')')) { if (token_buffer.length() > 0) { token_buffer += '\0'; argv[argc] = strsave(token_buffer.contents()); } // for `foo()', argc = 0 if (argc > 0 || c != ')' || i > 0) argc++; break; } token_buffer += char(c); if (c == '(') level++; else if (c == ')') level--; } } while (c != ')' && c != EOF); current_input = new argument_macro_input(body, argc, argv, current_input); }
/*================================================================= * advedit_expand_traverse -- Traverse routine called when expanding record *===============================================================*/ static BOOLEAN advedit_expand_traverse (NODE node, VPTR param) { LIST subs = (LIST)param; STRING key = value_to_xref(nval(node)); if (!key) return TRUE; key = strsave(key); #ifdef DEBUG llwprintf("expand_traverse: %s %s\n", ntag(node), nval(node)); #endif /* DEBUG */ FORLIST(subs, el) #ifdef DEBUG llwprintf("expand_traverse: %s %s\n", key, rmvat(nval((NODE) el))); #endif /* DEBUG */ if (eqstr(key, rmvat(nval((NODE) el)))) { STOPLIST stdfree(key); return TRUE; } ENDLIST enqueue_list(subs, node); stdfree(key); return TRUE; }
/************************************************************************* * R E A D L I S T * * Read a list of strings from a file. Return the string list to the * caller. *************************************************************************/ LIST read_list(const char *filename) { FILE *infile; char s[CHARS_PER_LINE]; LIST list; char *chopAt250(); if ((infile = open_file (filename, "r")) == NULL) return (NIL_LIST); list = NIL_LIST; while (fgets (s, CHARS_PER_LINE, infile) != NULL) { s[CHARS_PER_LINE - 1] = '\0'; if (strlen (s) > 0) { if (s[strlen (s) - 1] == '\n') s[strlen (s) - 1] = '\0'; if (strlen (s) > 0) { list = push (list, (LIST) strsave (s)); } } } fclose(infile); return (reverse_d (list)); }
yylex() { int k; STRING strsave(); STRING getstring(),getword(); float getnum(); while(iswhite(c=lexgetc())); if ( (isalpha(c)||c=='@') && c!=EOF ) { s = getword(c); if ((k=keyfind(s))!=NKEYWORDS && cconst) { yylval.strg = keywords[k].keyname; cconst=false; return(keywords[k].keyret); } yylval.strg = s; return(WORD); } if ( isdigit(c)||c=='~' ){ yylval.numb=(float)getnum(c); return(NUMB);} if ( c=='`') { c = lexgetc(); yylval.strg=getstring(c); return(STRING_QUOTED); } if ( c == '[' ) cconst=true; return(c); }
int main(int argc, char **argv) { setlocale(LC_NUMERIC, "C"); program_name = argv[0]; string env; static char stderr_buf[BUFSIZ]; setbuf(stderr, stderr_buf); int c; static const struct option long_options[] = { { "help", no_argument, 0, CHAR_MAX + 1 }, { "version", no_argument, 0, 'v' }, { NULL, 0, 0, 0 } }; while ((c = getopt_long(argc, argv, "b:c:F:gI:lmp:P:vw:", long_options, NULL)) != EOF) switch(c) { case 'b': // XXX check this broken_flags = atoi(optarg); bflag = 1; break; case 'c': if (sscanf(optarg, "%d", &ncopies) != 1 || ncopies <= 0) { error("bad number of copies `%s'", optarg); ncopies = 1; } break; case 'F': font::command_line_font_dir(optarg); break; case 'g': guess_flag = 1; break; case 'I': include_search_path.command_line_dir(optarg); break; case 'l': landscape_flag = 1; break; case 'm': manual_feed_flag = 1; break; case 'p': if (!font::scan_papersize(optarg, 0, &user_paper_length, &user_paper_width)) error("invalid custom paper size `%1' ignored", optarg); break; case 'P': env = "GROPS_PROLOGUE"; env += '='; env += optarg; env += '\0'; if (putenv(strsave(env.contents()))) fatal("putenv failed"); break; case 'v': printf("GNU grops (groff) version %s\n", Version_string); exit(0); break; case 'w': if (sscanf(optarg, "%d", &linewidth) != 1 || linewidth < 0) { error("bad linewidth `%1'", optarg); linewidth = -1; } break; case CHAR_MAX + 1: // --help usage(stdout); exit(0); break; case '?': usage(stderr); exit(1); break; default: assert(0); } font::set_unknown_desc_command_handler(handle_unknown_desc_command); SET_BINARY(fileno(stdout)); if (optind >= argc) do_file("-"); else { for (int i = optind; i < argc; i++) do_file(argv[i]); } return 0; }
void do_picture(FILE *fp) { flyback_flag = 0; int c; a_delete graphname; graphname = strsave("graph"); // default picture name in TeX mode while ((c = getc(fp)) == ' ') ; if (c == '<') { string filename; while ((c = getc(fp)) == ' ') ; while (c != EOF && c != ' ' && c != '\n') { filename += char(c); c = getc(fp); } if (c == ' ') { do { c = getc(fp); } while (c != EOF && c != '\n'); } if (c == '\n') current_lineno++; if (filename.length() == 0) error("missing filename after `<'"); else { filename += '\0'; const char *old_filename = current_filename; int old_lineno = current_lineno; // filenames must be permanent do_file(strsave(filename.contents())); current_filename = old_filename; current_lineno = old_lineno; } out->set_location(current_filename, current_lineno); } else { out->set_location(current_filename, current_lineno); string start_line; while (c != EOF) { if (c == '\n') { current_lineno++; break; } start_line += c; c = getc(fp); } if (c == EOF) return; start_line += '\0'; double wid, ht; switch (sscanf(&start_line[0], "%lf %lf", &wid, &ht)) { case 1: ht = 0.0; break; case 2: break; default: ht = wid = 0.0; break; } out->set_desired_width_height(wid, ht); out->set_args(start_line.contents()); lex_init(new top_input(fp)); if (yyparse()) { had_parse_error = 1; lex_error("giving up on this picture"); } parse_cleanup(); lex_cleanup(); // skip the rest of the .PF/.PE line while ((c = getc(fp)) != EOF && c != '\n') ; if (c == '\n') current_lineno++; out->set_location(current_filename, current_lineno); } }