From: kristaps@mdocml.bsd.lv
To: source@mdocml.bsd.lv
Subject: mdocml: Filter all \N'' values with isprint().
Date: Sun, 1 May 2011 04:38:56 -0400 (EDT) [thread overview]
Message-ID: <201105010838.p418cuTN013649@krisdoz.my.domain> (raw)
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
reply other threads:[~2011-05-01 8:38 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=201105010838.p418cuTN013649@krisdoz.my.domain \
--to=kristaps@mdocml.bsd.lv \
--cc=source@mdocml.bsd.lv \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).