hun#1724558 tidy substrings.c a little
This commit is contained in:
parent
5020b64b0e
commit
7107dea0c0
|
@ -1,3 +1,6 @@
|
||||||
|
2010-03-04 Caolán McNamara <cmc at OOo>:
|
||||||
|
- hun#1724558 tidy substring.c a little
|
||||||
|
|
||||||
2010-02-23 László Németh <nemeth at OOo>:
|
2010-02-23 László Németh <nemeth at OOo>:
|
||||||
* hyphen.c: fix lefthyphenmin calculation for UTF-8 encoded input
|
* hyphen.c: fix lefthyphenmin calculation for UTF-8 encoded input
|
||||||
|
|
||||||
|
|
|
@ -119,7 +119,7 @@ main(int argc, char** argv)
|
||||||
|
|
||||||
|
|
||||||
/* now read each word from the wtc file */
|
/* now read each word from the wtc file */
|
||||||
while(fgets(buf,BUFSIZE,wtclst)) {
|
while(fgets(buf,BUFSIZE,wtclst) != NULL) {
|
||||||
k = strlen(buf);
|
k = strlen(buf);
|
||||||
if (buf[k - 1] == '\n') buf[k - 1] = '\0';
|
if (buf[k - 1] == '\n') buf[k - 1] = '\0';
|
||||||
if (*buf && buf[k - 2] == '\r') buf[k-- - 2] = '\0';
|
if (*buf && buf[k - 2] == '\r') buf[k-- - 2] = '\0';
|
||||||
|
|
|
@ -180,7 +180,7 @@ int main(int argc, const char* argv[]) {
|
||||||
if ((in = fopen(argv[1],"r"))==NULL) die("Could not read input");
|
if ((in = fopen(argv[1],"r"))==NULL) die("Could not read input");
|
||||||
if ((out = fopen(argv[2],"w"))==NULL) die("Could not create output");
|
if ((out = fopen(argv[2],"w"))==NULL) die("Could not create output");
|
||||||
// read all patterns and split in pure text (_key) & expanded patterns (_val)
|
// read all patterns and split in pure text (_key) & expanded patterns (_val)
|
||||||
while(fgets(format,132,in)) {
|
while(fgets(format,132,in) != NULL) {
|
||||||
int l = strlen(format);
|
int l = strlen(format);
|
||||||
if (format[l-1]=='\n') { l--; format[l]=0; } // Chomp
|
if (format[l-1]=='\n') { l--; format[l]=0; } // Chomp
|
||||||
if (format[0]=='%' || format[0]==0) {
|
if (format[0]=='%' || format[0]==0) {
|
||||||
|
@ -193,6 +193,7 @@ int main(int argc, const char* argv[]) {
|
||||||
int i,j;
|
int i,j;
|
||||||
char *pat = (char*) malloc(l+1);
|
char *pat = (char*) malloc(l+1);
|
||||||
char *org = (char*) malloc(l*2+1);
|
char *org = (char*) malloc(l*2+1);
|
||||||
|
if (pat==NULL || org==NULL) die("not enough memory");
|
||||||
expand(org,format,l);
|
expand(org,format,l);
|
||||||
// remove hyphenation encoders (digits) from pat
|
// remove hyphenation encoders (digits) from pat
|
||||||
for (i=0,j=0; i<l; i++) {
|
for (i=0,j=0; i<l; i++) {
|
||||||
|
@ -224,10 +225,12 @@ int main(int argc, const char* argv[]) {
|
||||||
if ((subpat_ndx = find_in(pattab_key,patterns,subpat))>=0) {
|
if ((subpat_ndx = find_in(pattab_key,patterns,subpat))>=0) {
|
||||||
int newpat_ndx;
|
int newpat_ndx;
|
||||||
char *newpat=malloc(l+1);
|
char *newpat=malloc(l+1);
|
||||||
|
if (newpat==NULL) die("not enough memory");
|
||||||
//printf("%s is embedded in %s\n",pattab_val[subpat_ndx],pattab_val[p]);
|
//printf("%s is embedded in %s\n",pattab_val[subpat_ndx],pattab_val[p]);
|
||||||
strncpy(newpat, pat+0,l); newpat[l]=0;
|
strncpy(newpat, pat+0,l); newpat[l]=0;
|
||||||
if ((newpat_ndx = find_in(newpattab_key,newpatterns,newpat))<0) {
|
if ((newpat_ndx = find_in(newpattab_key,newpatterns,newpat))<0) {
|
||||||
char *neworg = malloc(132); // TODO: compute exact length
|
char *neworg = malloc(132); // TODO: compute exact length
|
||||||
|
if (neworg==NULL) die("not enough memory");
|
||||||
expand(neworg,newpat,l);
|
expand(neworg,newpat,l);
|
||||||
newpattab_key[newpatterns] = newpat;
|
newpattab_key[newpatterns] = newpat;
|
||||||
newpattab_val[newpatterns++] = combine(neworg,pattab_val[subpat_ndx]);
|
newpattab_val[newpatterns++] = combine(neworg,pattab_val[subpat_ndx]);
|
||||||
|
|
Loading…
Reference in New Issue