|
From: Markus R. <rol...@us...> - 2007-04-25 20:27:21
|
Update of /cvsroot/simspark/simspark/spark/utility/sfsexp In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv10140 Modified Files: Tag: RSGEDIT_FILEREF parser.c sexp.c sexp.h sexp_ops.c Log Message: - attribute parsed s_expression with a line number; a 'line' member is therefore added to sexp_t - maintain a line counter in the parser and increment whenever a \n is read. Copy current line counter in every create sexp_t instance Index: sexp.h =================================================================== RCS file: /cvsroot/simspark/simspark/spark/utility/sfsexp/sexp.h,v retrieving revision 1.1.6.1 retrieving revision 1.1.6.2 diff -C2 -d -r1.1.6.1 -r1.1.6.2 *** sexp.h 25 Apr 2007 20:24:35 -0000 1.1.6.1 --- sexp.h 25 Apr 2007 20:27:17 -0000 1.1.6.2 *************** *** 291,294 **** --- 291,299 ---- */ unsigned int binlength; + + /** + * The line number of the element start + */ + unsigned int line; } sexp_t; *************** *** 462,465 **** --- 467,475 ---- */ char *bindata; + + /** + * The current line number, i.e. the number of \n seen + */ + unsigned int line; } pcont_t; Index: parser.c =================================================================== RCS file: /cvsroot/simspark/simspark/spark/utility/sfsexp/parser.c,v retrieving revision 1.1.6.1 retrieving revision 1.1.6.2 diff -C2 -d -r1.1.6.1 -r1.1.6.2 *** parser.c 25 Apr 2007 20:24:35 -0000 1.1.6.1 --- parser.c 25 Apr 2007 20:27:17 -0000 1.1.6.2 *************** *** 330,333 **** --- 330,334 ---- cc->qdepth = 0; cc->squoted = 0; + cc->line = 1; return cc; *************** *** 458,461 **** --- 459,464 ---- t = s; cc->sbuffer = str; + + cc->line = 1; } *************** *** 487,490 **** --- 490,497 ---- /* space,tab,CR,LF considered white space */ case '\n': + cc->line++; + t++; + break; + case ' ': case '\t': *************** *** 567,570 **** --- 574,578 ---- sx->next = NULL; sx->list = NULL; + sx->line = cc->line; if (stack->height < 1) *************** *** 708,711 **** --- 716,721 ---- sx->val_used = val_used; sx->next = NULL; + sx->line = cc->line; + if (squoted != 0) sx->aty = SEXP_SQUOTE; *************** *** 838,841 **** --- 848,852 ---- sx->val_allocated = val_allocated; sx->next = NULL; + sx->line = cc->line; if (squoted == 1) { *************** *** 993,996 **** --- 1004,1008 ---- sx->next = NULL; sx->aty = SEXP_SQUOTE; + sx->line = cc->line; val = (char *)malloc(sizeof(char)*sexp_val_start_size); *************** *** 1060,1063 **** --- 1072,1076 ---- case 11: if (t[0] == '\n') { + cc->line++; state = 1; } *************** *** 1161,1164 **** --- 1174,1178 ---- sx->next = NULL; sx->aty = SEXP_BINARY; + sx->line = cc->line; bindata = NULL; Index: sexp_ops.c =================================================================== RCS file: /cvsroot/simspark/simspark/spark/utility/sfsexp/sexp_ops.c,v retrieving revision 1.1.6.1 retrieving revision 1.1.6.2 diff -C2 -d -r1.1.6.1 -r1.1.6.2 *** sexp_ops.c 25 Apr 2007 20:24:35 -0000 1.1.6.1 --- sexp_ops.c 25 Apr 2007 20:27:17 -0000 1.1.6.2 *************** *** 147,150 **** --- 147,151 ---- } + snew->line = s->line; snew->next = copy_sexp(s->next); *************** *** 218,221 **** --- 219,224 ---- /* copy the head of the sexpr */ + cr->line = s->line; + if (s->list->ty == SEXP_VALUE) { cr->ty = SEXP_VALUE; *************** *** 257,260 **** --- 260,264 ---- cd->next = NULL; cd->list = copy_sexp(s->list->next); + cd->line = s->line; return cd; } Index: sexp.c =================================================================== RCS file: /cvsroot/simspark/simspark/spark/utility/sfsexp/sexp.c,v retrieving revision 1.2.2.1 retrieving revision 1.2.2.2 diff -C2 -d -r1.2.2.1 -r1.2.2.2 *** sexp.c 25 Apr 2007 20:24:35 -0000 1.2.2.1 --- sexp.c 25 Apr 2007 20:27:17 -0000 1.2.2.2 *************** *** 96,99 **** --- 96,100 ---- fakehead->next = NULL; /* this is the important part of fakehead */ fakehead->aty = sx->aty; + fakehead->line = 0; if (fakehead->ty == SEXP_VALUE) { *************** *** 342,345 **** --- 343,347 ---- fakehead->next = NULL; /* this is the important part of fakehead */ fakehead->aty = sx->aty; + fakehead->line = 0; if (fakehead->ty == SEXP_VALUE) { *************** *** 476,479 **** --- 478,483 ---- sx->val_used = sx->val_allocated = 0; + sx->line = 0; + return sx; } *************** *** 496,499 **** --- 500,505 ---- sx->list = sx->next = NULL; + sx->line = 0; + return sx; } |