From b05e3d542b9440ea08758788a4c859a842de4f5d Mon Sep 17 00:00:00 2001 From: Joey Schulze Date: Fri, 22 Feb 2002 11:25:11 +0000 Subject: [PATCH] Fix problems with unproperly recognized values like "10,03", "100.004" and "30". They're now forced to be of form "nnnnn.pp". --- dtaus.c | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/dtaus.c b/dtaus.c index 7c7ea71..f3fc082 100644 --- a/dtaus.c +++ b/dtaus.c @@ -1027,6 +1027,7 @@ int control2dtaus (char *ccontrol, char *cdtaus, char *cbeleg, char *ccheck) char **text = NULL; char *cp; int textindex = 0; + int len, i; if (!cdtaus) { if (!(fdtaus = fopen("dtaus0.txt", "w"))) @@ -1185,10 +1186,31 @@ int control2dtaus (char *ccontrol, char *cdtaus, char *cbeleg, char *ccheck) } } } else { - if ((valC[recindex] = (char *)malloc (strlen(line)+1))) - strcpy(valC[recindex], line); - else - return 0; + len = strlen(line); + if (recindex == C_VAL) { + /* Convert commast to dots for later processing */ + for (i=0; line[i]; i++) if (line[i] == ',') line[i] = '.'; + + if ((cp = index (line, '.')) == NULL) { + if (!(valC[recindex] = (char *)malloc (strlen(line)+4))) + return 0; + sprintf (valC[recindex], "%s.00", line); + } else if ( ((len = cp - line + 3)) < strlen (line)) { + if (!(valC[recindex] = (char *)malloc (len+1))) + return 0; + strncpy (valC[recindex], line, len); + valC[recindex][len] = '\0'; + } else { + if (!(valC[recindex] = (char *)malloc (strlen(line)+1))) + return 0; + strcpy(valC[recindex], line); + } + } else { + if ((valC[recindex] = (char *)malloc (strlen(line)+1))) + strcpy(valC[recindex], line); + else + return 0; + } } } control_nextline ((void *)line, 100, fcontrol); -- 2.20.1