X-Git-Url: https://git.jankratochvil.net/?p=timeplan.git;a=blobdiff_plain;f=timeplan.c;h=357f9d047b5ad1a03448db38fedf92375ade2d35;hp=61d71f91fc3e64d3897675fb6b41e2071946350d;hb=a8c2028ced26bf5950b0f81d92bafddc93d0a053;hpb=2c28e4080e000cfe44ad45776162bfc7405b3c43 diff --git a/timeplan.c b/timeplan.c index 61d71f9..357f9d0 100644 --- a/timeplan.c +++ b/timeplan.c @@ -358,7 +358,7 @@ static char *modify(char *what) { regmatch_t matches[10]; int i,m; -int doprep; +int doprep,willprep; static char modbuf1[sizeof(buf)],modbuf2[sizeof(modbuf1)]; char *src=what,*dstbase=modbuf1,*dst=dstbase; const char *start FAKEUSE,*end FAKEUSE,*patt; @@ -366,10 +366,10 @@ const struct textlist *item; if (verbose) printf("modify: %s\n",what); modify_load(); - for (m=0,item=modifies;;m++,item=item->next) { + for (m=0,item=modifies,willprep=1;;m++,item=item->next) { enum { PATT_START,PATT_MID,PATT_END,PATT_TERM } pattpos; - for (doprep=1;doprep>=0;doprep--) { + for (doprep=willprep;doprep>=0;doprep--) { if (doprep) { *dst++='-'; for (patt=src;;patt++) { @@ -384,12 +384,18 @@ enum { PATT_START,PATT_MID,PATT_END,PATT_TERM } pattpos; } } else { + if (!item) + return src; i=regexec(&modistructs[m].regex,src,LENGTH(matches),matches,0); - if (i==REG_NOMATCH) continue; + if (i==REG_NOMATCH) { + willprep=0; + break; + } if (i) { fprintf(ERRH1"regexec() failed for \"%s\""ERRNO1,ERRH2,item->text,ERRNO2); exit(EXIT_FAILURE); } + willprep=1; if (verbose) printf("matched: %s -> %s\n",item->text,modistructs[m].dst); pattpos=PATT_START; patt=NULL; while (pattpos!=PATT_TERM) { @@ -459,8 +465,6 @@ enum { PATT_START,PATT_MID,PATT_END,PATT_TERM } pattpos; ||(src==modbuf2 && dstbase==modbuf1)); swap=src; src=dstbase; dst=dstbase=swap; } - if (!item) - return src; } /* for (doprep) */ } /* NOTREACHED */