mirror of https://gerrit.osmocom.org/asn1c
recognize comments
git-svn-id: https://asn1c.svn.sourceforge.net/svnroot/asn1c/trunk@815 59561ff5-6e30-0410-9f3c-9617f08c8826
This commit is contained in:
parent
a3f2eea887
commit
8e8eca7b34
|
@ -1,5 +1,5 @@
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 2004 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
* Copyright (c) 2004, 2005 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
|
@ -35,7 +35,7 @@
|
||||||
|
|
||||||
#undef COPYRIGHT
|
#undef COPYRIGHT
|
||||||
#define COPYRIGHT \
|
#define COPYRIGHT \
|
||||||
"Copyright (c) 2004 Lev Walkin <vlm@lionet.info>\n"
|
"Copyright (c) 2004, 2005 Lev Walkin <vlm@lionet.info>\n"
|
||||||
|
|
||||||
static void usage(const char *av0, int);/* Print the Usage screen and exit */
|
static void usage(const char *av0, int);/* Print the Usage screen and exit */
|
||||||
static int process(const char *fname); /* Perform the BER decoding */
|
static int process(const char *fname); /* Perform the BER decoding */
|
||||||
|
@ -58,9 +58,6 @@ main(int ac, char **av) {
|
||||||
break;
|
break;
|
||||||
case 'v':
|
case 'v':
|
||||||
usage(av[0], 1);
|
usage(av[0], 1);
|
||||||
fprintf(stderr, "Convert unber(1)'s output back into BER, "
|
|
||||||
"v" VERSION "\n" COPYRIGHT);
|
|
||||||
exit(0);
|
|
||||||
break;
|
break;
|
||||||
case 'h':
|
case 'h':
|
||||||
default:
|
default:
|
||||||
|
@ -209,14 +206,16 @@ process_line(const char *fname, char *line, int lineno) {
|
||||||
}
|
}
|
||||||
cl = line;
|
cl = line;
|
||||||
if(*cl != '>') {
|
if(*cl != '>') {
|
||||||
fprintf(stderr, "%s: Missing '>'\n", fname);
|
fprintf(stderr, "%s: Missing '>' at line %d\n", fname, lineno);
|
||||||
exit(EX_DATAERR);
|
exit(EX_DATAERR);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Ignore closing tags */
|
/* Ignore closing tags */
|
||||||
if(op[1] == '/') {
|
if(op[1] == '/') {
|
||||||
if(strchr(cl, '<')) { /* We are not very robust */
|
if(strchr(cl, '<')) { /* We are not very robust */
|
||||||
fprintf(stderr, "%s: Multiple tags per line\n", fname);
|
fprintf(stderr,
|
||||||
|
"%s: Multiple tags per line at line %d\n",
|
||||||
|
fname, lineno);
|
||||||
exit(EX_DATAERR);
|
exit(EX_DATAERR);
|
||||||
}
|
}
|
||||||
/* End-of-content octets */
|
/* End-of-content octets */
|
||||||
|
@ -228,20 +227,23 @@ process_line(const char *fname, char *line, int lineno) {
|
||||||
}
|
}
|
||||||
|
|
||||||
switch(op[1]) {
|
switch(op[1]) {
|
||||||
|
case '!': return 0; /* A comment */
|
||||||
|
case '?': return 0; /* An XML preamble */
|
||||||
case 'C': constr = 1; break;
|
case 'C': constr = 1; break;
|
||||||
case 'P': constr = 0; break;
|
case 'P': constr = 0; break;
|
||||||
case 'I': constr = 2; break;
|
case 'I': constr = 2; break;
|
||||||
default:
|
default:
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"%s: Expected \"C\"/\"P\"/\"I\" as the XML tag name (%c)\n",
|
"%s: Expected \"C\"/\"P\"/\"I\" as the XML tag name (%c) at line %d\n",
|
||||||
fname, op[1]);
|
fname, op[1], lineno);
|
||||||
exit(EX_DATAERR);
|
exit(EX_DATAERR);
|
||||||
}
|
}
|
||||||
|
|
||||||
*cl = '\0';
|
*cl = '\0';
|
||||||
if(cl[-1] == 'F') {
|
if(cl[-1] == 'F') {
|
||||||
fprintf(stderr, "%s: Uses pretty-printing of values. "
|
fprintf(stderr,
|
||||||
"Use -p option to unber\n", fname);
|
"%s: Detected pretty-printing of primitive types at line %d. "
|
||||||
|
"Re-run `unber` with -p option to disable pretty-printing.\n", fname, lineno);
|
||||||
exit(EX_DATAERR);
|
exit(EX_DATAERR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue