Sanitize Name and Location given in the command line.

Fix the bug with 8bit chars in the Name & Location in the text output.
This commit is contained in:
Andrey A. Chernov 2007-06-23 14:20:21 +00:00
parent ba5ad24a2c
commit eb0925e19a
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=194123
3 changed files with 53 additions and 5 deletions

View file

@ -10,7 +10,7 @@
PORTNAME= astrolog PORTNAME= astrolog
PORTVERSION= 5.40 PORTVERSION= 5.40
PORTREVISION= 4 PORTREVISION= 5
CATEGORIES= misc CATEGORIES= misc
MASTER_SITES= http://www.astrolog.org/ftp/ephem/:ephem \ MASTER_SITES= http://www.astrolog.org/ftp/ephem/:ephem \
http://www.astrolog.org/ftp/:dist http://www.astrolog.org/ftp/:dist

View file

@ -1,6 +1,14 @@
--- astrolog.c.orig Wed Dec 23 23:29:16 1998 --- astrolog.c.orig 1998-12-23 23:29:07.000000000 +0300
+++ astrolog.c Fri May 25 21:07:58 2001 +++ astrolog.c 2007-06-23 18:07:49.000000000 +0400
@@ -1146,8 +1146,18 @@ @@ -35,6 +35,7 @@
** Last code change made 12/20/1998.
*/
+#include <ctype.h>
#include "astrolog.h"
@@ -1146,8 +1147,18 @@
case 'z': case 'z':
if (ch1 == '0') { if (ch1 == '0') {
if (argc <= 1 || RParseSz(argv[1], pmZon) == rLarge) { if (argc <= 1 || RParseSz(argv[1], pmZon) == rLarge) {
@ -21,7 +29,27 @@
SS = us.dstDef = i ? 1.0 : 0.0; SS = us.dstDef = i ? 1.0 : 0.0;
} else { } else {
SS = us.dstDef = RParseSz(argv[1], pmZon); SS = us.dstDef = RParseSz(argv[1], pmZon);
@@ -1236,9 +1246,19 @@ @@ -1232,13 +1243,39 @@
return fFalse;
}
ciCore.nam = SzPersist(argv[1]);
+ if (CchSz(ciCore.nam) > 25) /* see xcharts0.c */
+ ciCore.nam[25] = chNull;
+ for (pch = ciCore.nam; *pch; pch++) {
+ if (*pch == '"') /* see io.c */
+ *pch = '\'';
+ else if (iscntrl((_char)*pch)) /* see xgeneral.c */
+ *pch = ' ';
+ }
ciCore.loc = SzPersist(argv[2]);
+ if (CchSz(ciCore.loc) > 25) /* see xcharts0.c */
+ ciCore.loc[25] = chNull;
+ for (pch = ciCore.loc; *pch; pch++) {
+ if (*pch == '"') /* see io.c */
+ *pch = '\'';
+ else if (iscntrl((_char)*pch)) /* see xgeneral.c */
+ *pch = ' ';
+ }
argc -= 2; argv += 2; argc -= 2; argv += 2;
break; break;
} }

View file

@ -0,0 +1,20 @@
--- charts1.c.bak 1998-12-23 23:29:26.000000000 +0300
+++ charts1.c 2007-06-23 16:28:33.000000000 +0400
@@ -53,7 +53,7 @@
char sz[cchSzDef];
int day, fNam, fLoc;
- fNam = *ciMain.nam > chNull; fLoc = *ciMain.loc > chNull;
+ fNam = *ciMain.nam != chNull; fLoc = *ciMain.loc != chNull;
AnsiColor(kWhite);
sprintf(sz, "%s %s chart ", szAppName, szVersionCore); PrintSz(sz);
if (fNoTimeOrSpace)
@@ -83,7 +83,7 @@
real rT;
CreateElemTable(&et);
- fNam = *ciMain.nam > chNull; fLoc = *ciMain.loc > chNull;
+ fNam = *ciMain.nam != chNull; fLoc = *ciMain.loc != chNull;
PrintHeader(); /* Show time and date of the chart being displayed. */