* mdocml: Filter all \N'' values with isprint().
@ 2011-05-01 8:38 kristaps
0 siblings, 0 replies; only message in thread
From: kristaps @ 2011-05-01 8:38 UTC (permalink / raw)
To: source
Log Message:
-----------
Filter all \N'' values with isprint(). Ok schwarze@.
Modified Files:
--------------
mdocml:
chars.c
Revision Data
-------------
Index: chars.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/chars.c,v
retrieving revision 1.39
retrieving revision 1.40
diff -Lchars.c -Lchars.c -u -p -r1.39 -r1.40
--- chars.c
+++ chars.c
@@ -20,6 +20,7 @@
#endif
#include <assert.h>
+#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -135,9 +136,11 @@ mchars_res2cp(struct mchars *arg, const
return(ln->unicode);
}
-
/*
* Numbered character to literal character.
+ * This can only be a printable character (i.e., alnum, punct, space) so
+ * prevent the character from ruining our state (backspace, newline, and
+ * so on).
*/
char
mchars_num2char(const char *p, size_t sz)
@@ -148,15 +151,9 @@ mchars_num2char(const char *p, size_t sz
return('\0');
i = atoi(p);
- /*
- * FIXME:
- * This is wrong. Anything could be written here!
- * This should be carefully screened for possible characters.
- */
- return(i <= 0 || i > 255 ? '\0' : (char)i);
+ return(isprint(i) ? (char)i : '\0');
}
-
/*
* Special character to string array.
*/
@@ -172,7 +169,6 @@ mchars_spec2str(struct mchars *arg, cons
*rsz = strlen(ln->ascii);
return(ln->ascii);
}
-
/*
* Reserved word to string array.
--
To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2011-05-01 8:38 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-01 8:38 mdocml: Filter all \N'' values with isprint() kristaps
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).