mirror of
https://git.FreeBSD.org/src.git
synced 2024-10-19 02:29:40 +00:00
Merge from the vendor branch and resolve conflicts.
This commit is contained in:
parent
5f06c5bb28
commit
5768032947
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=178846
@ -34,7 +34,7 @@
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
RCSID("$Id: com_err.c,v 1.18 2002/03/10 23:07:01 assar Exp $");
|
||||
RCSID("$Id: com_err.c 14930 2005-04-24 19:43:06Z lha $");
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@ -51,15 +51,14 @@ error_message (long code)
|
||||
const char *p = com_right(_et_list, code);
|
||||
if (p == NULL) {
|
||||
if (code < 0)
|
||||
sprintf(msg, "Unknown error %ld", code);
|
||||
snprintf(msg, sizeof(msg), "Unknown error %ld", code);
|
||||
else
|
||||
p = strerror(code);
|
||||
}
|
||||
if (p != NULL && *p != '\0') {
|
||||
strncpy(msg, p, sizeof(msg) - 1);
|
||||
msg[sizeof(msg) - 1] = 0;
|
||||
strlcpy(msg, p, sizeof(msg));
|
||||
} else
|
||||
sprintf(msg, "Unknown error %ld", code);
|
||||
snprintf(msg, sizeof(msg), "Unknown error %ld", code);
|
||||
return msg;
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,7 @@
|
||||
*/
|
||||
|
||||
/* $FreeBSD$ */
|
||||
/* $Id: com_err.h,v 1.9 2001/05/11 20:03:36 assar Exp $ */
|
||||
/* $Id: com_err.h 15566 2005-07-07 14:58:07Z lha $ */
|
||||
|
||||
/* MIT compatible com_err library */
|
||||
|
||||
@ -43,11 +43,12 @@
|
||||
#include <stdarg.h>
|
||||
|
||||
#include <com_right.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
typedef void (*errf) __P((const char *, long, const char *, va_list));
|
||||
|
||||
const char * error_message __P((long));
|
||||
int init_error_table __P((const char**, long, int));
|
||||
const char * error_message (long);
|
||||
int init_error_table (const char**, long, int);
|
||||
|
||||
void com_err_va __P((const char *, long, const char *, va_list))
|
||||
__printflike(3, 0);
|
||||
@ -55,11 +56,11 @@ void com_err_va __P((const char *, long, const char *, va_list))
|
||||
void com_err __P((const char *, long, const char *, ...))
|
||||
__printflike(3, 4);
|
||||
|
||||
errf set_com_err_hook __P((errf));
|
||||
errf reset_com_err_hook __P((void));
|
||||
errf set_com_err_hook (errf);
|
||||
errf reset_com_err_hook (void);
|
||||
|
||||
const char *error_table_name __P((int num));
|
||||
const char *error_table_name (int num);
|
||||
|
||||
void add_to_error_table __P((struct et_list *new_table));
|
||||
void add_to_error_table (struct et_list *new_table);
|
||||
|
||||
#endif /* __COM_ERR_H__ */
|
||||
|
@ -31,7 +31,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/* $Id: com_right.h,v 1.11 2000/07/31 01:11:08 assar Exp $ */
|
||||
/* $Id: com_right.h 14551 2005-02-03 08:45:13Z lha $ */
|
||||
/* $FreeBSD$ */
|
||||
|
||||
#ifndef __COM_RIGHT_H__
|
||||
@ -51,8 +51,8 @@ struct et_list {
|
||||
};
|
||||
extern struct et_list *_et_list;
|
||||
|
||||
const char *com_right __P((struct et_list *list, long code));
|
||||
void initialize_error_table_r __P((struct et_list **, const char **, int, long));
|
||||
void free_error_table __P((struct et_list *));
|
||||
const char *com_right (struct et_list *list, long code);
|
||||
void initialize_error_table_r (struct et_list **, const char **, int, long);
|
||||
void free_error_table (struct et_list *);
|
||||
|
||||
#endif /* __COM_RIGHT_H__ */
|
||||
|
@ -37,7 +37,7 @@
|
||||
#include <getarg.h>
|
||||
|
||||
#if 0
|
||||
RCSID("$Id: compile_et.c,v 1.16 2002/08/20 12:44:51 joda Exp $");
|
||||
RCSID("$Id: compile_et.c 15426 2005-06-16 19:21:42Z lha $");
|
||||
#endif
|
||||
|
||||
#include <err.h>
|
||||
@ -48,7 +48,7 @@ extern FILE *yyin;
|
||||
|
||||
extern void yyparse(void);
|
||||
|
||||
long base;
|
||||
long base_id;
|
||||
int number;
|
||||
char *prefix;
|
||||
char *id_str;
|
||||
@ -158,13 +158,13 @@ generate_h(void)
|
||||
fprintf(h_file, "typedef enum %s_error_number{\n", name);
|
||||
|
||||
for(ec = codes; ec; ec = ec->next) {
|
||||
fprintf(h_file, "\t%s = %ld%s\n", ec->name, base + ec->number,
|
||||
fprintf(h_file, "\t%s = %ld%s\n", ec->name, base_id + ec->number,
|
||||
(ec->next != NULL) ? "," : "");
|
||||
}
|
||||
|
||||
fprintf(h_file, "} %s_error_number;\n", name);
|
||||
fprintf(h_file, "\n");
|
||||
fprintf(h_file, "#define ERROR_TABLE_BASE_%s %ld\n", name, base);
|
||||
fprintf(h_file, "#define ERROR_TABLE_BASE_%s %ld\n", name, base_id);
|
||||
fprintf(h_file, "\n");
|
||||
fprintf(h_file, "#endif /* %s */\n", fn);
|
||||
|
||||
@ -196,17 +196,17 @@ int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
char *p;
|
||||
int optind = 0;
|
||||
int optidx = 0;
|
||||
|
||||
setprogname(argv[0]);
|
||||
if(getarg(args, num_args, argc, argv, &optind))
|
||||
if(getarg(args, num_args, argc, argv, &optidx))
|
||||
usage(1);
|
||||
if(help_flag)
|
||||
usage(0);
|
||||
|
||||
if(optind == argc)
|
||||
if(optidx == argc)
|
||||
usage(1);
|
||||
filename = argv[optind];
|
||||
filename = argv[optidx];
|
||||
yyin = fopen(filename, "r");
|
||||
if(yyin == NULL)
|
||||
err(1, "%s", filename);
|
||||
@ -217,8 +217,7 @@ main(int argc, char **argv)
|
||||
p++;
|
||||
else
|
||||
p = filename;
|
||||
strncpy(Basename, p, sizeof(Basename));
|
||||
Basename[sizeof(Basename) - 1] = '\0';
|
||||
strlcpy(Basename, p, sizeof(Basename));
|
||||
|
||||
Basename[strcspn(Basename, ".")] = '\0';
|
||||
|
||||
|
@ -31,7 +31,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/* $Id: compile_et.h,v 1.6 2000/07/01 20:21:48 assar Exp $ */
|
||||
/* $Id: compile_et.h 15426 2005-06-16 19:21:42Z lha $ */
|
||||
/* $FreeBSD$ */
|
||||
|
||||
#ifndef __COMPILE_ET_H__
|
||||
@ -41,13 +41,14 @@
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <err.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <ctype.h>
|
||||
|
||||
extern long base;
|
||||
extern long base_id;
|
||||
extern int number;
|
||||
extern char *prefix;
|
||||
extern char name[128];
|
||||
|
@ -46,7 +46,7 @@
|
||||
#include "lex.h"
|
||||
|
||||
#if 0
|
||||
RCSID("$Id: lex.l,v 1.6 2000/06/22 00:42:52 assar Exp $");
|
||||
RCSID("$Id: lex.l 15143 2005-05-16 08:52:54Z lha $");
|
||||
#endif
|
||||
|
||||
static unsigned lineno = 1;
|
||||
@ -92,7 +92,7 @@ getstring(void)
|
||||
int i = 0;
|
||||
int c;
|
||||
int quote = 0;
|
||||
while((c = input()) != EOF){
|
||||
while(i < sizeof(x) - 1 && (c = input()) != EOF){
|
||||
if(quote) {
|
||||
x[i++] = c;
|
||||
quote = 0;
|
||||
@ -113,6 +113,8 @@ getstring(void)
|
||||
}
|
||||
x[i] = '\0';
|
||||
yylval.string = strdup(x);
|
||||
if (yylval.string == NULL)
|
||||
err(1, "malloc");
|
||||
return STRING;
|
||||
}
|
||||
|
||||
|
@ -36,7 +36,7 @@
|
||||
#include "compile_et.h"
|
||||
#include "lex.h"
|
||||
#if 0
|
||||
RCSID("$Id: parse.y,v 1.11 2000/06/22 00:42:52 assar Exp $");
|
||||
RCSID("$Id: parse.y 15426 2005-06-16 19:21:42Z lha $");
|
||||
#endif
|
||||
|
||||
void yyerror (char *s);
|
||||
@ -79,16 +79,14 @@ id : ID STRING
|
||||
|
||||
et : ET STRING
|
||||
{
|
||||
base = name2number($2);
|
||||
strncpy(name, $2, sizeof(name));
|
||||
name[sizeof(name) - 1] = '\0';
|
||||
base_id = name2number($2);
|
||||
strlcpy(name, $2, sizeof(name));
|
||||
free($2);
|
||||
}
|
||||
| ET STRING STRING
|
||||
{
|
||||
base = name2number($2);
|
||||
strncpy(name, $3, sizeof(name));
|
||||
name[sizeof(name) - 1] = '\0';
|
||||
base_id = name2number($2);
|
||||
strlcpy(name, $3, sizeof(name));
|
||||
free($2);
|
||||
free($3);
|
||||
}
|
||||
@ -104,24 +102,32 @@ statement : INDEX NUMBER
|
||||
}
|
||||
| PREFIX STRING
|
||||
{
|
||||
prefix = realloc(prefix, strlen($2) + 2);
|
||||
strcpy(prefix, $2);
|
||||
strcat(prefix, "_");
|
||||
free(prefix);
|
||||
asprintf (&prefix, "%s_", $2);
|
||||
if (prefix == NULL)
|
||||
errx(1, "malloc");
|
||||
free($2);
|
||||
}
|
||||
| PREFIX
|
||||
{
|
||||
prefix = realloc(prefix, 1);
|
||||
if (prefix == NULL)
|
||||
errx(1, "malloc");
|
||||
*prefix = '\0';
|
||||
}
|
||||
| EC STRING ',' STRING
|
||||
{
|
||||
struct error_code *ec = malloc(sizeof(*ec));
|
||||
|
||||
if (ec == NULL)
|
||||
errx(1, "malloc");
|
||||
|
||||
ec->next = NULL;
|
||||
ec->number = number;
|
||||
if(prefix && *prefix != '\0') {
|
||||
asprintf (&ec->name, "%s%s", prefix, $2);
|
||||
if (ec->name == NULL)
|
||||
errx(1, "malloc");
|
||||
free($2);
|
||||
} else
|
||||
ec->name = $2;
|
||||
@ -141,7 +147,7 @@ static long
|
||||
name2number(const char *str)
|
||||
{
|
||||
const char *p;
|
||||
long base = 0;
|
||||
long num = 0;
|
||||
const char *x = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||
"abcdefghijklmnopqrstuvwxyz0123456789_";
|
||||
if(strlen(str) > 4) {
|
||||
@ -154,12 +160,12 @@ name2number(const char *str)
|
||||
yyerror("invalid character in table name");
|
||||
return 0;
|
||||
}
|
||||
base = (base << 6) + (q - x) + 1;
|
||||
num = (num << 6) + (q - x) + 1;
|
||||
}
|
||||
base <<= 8;
|
||||
if(base > 0x7fffffff)
|
||||
base = -(0xffffffff - base + 1);
|
||||
return base;
|
||||
num <<= 8;
|
||||
if(num > 0x7fffffff)
|
||||
num = -(0xffffffff - num + 1);
|
||||
return num;
|
||||
}
|
||||
|
||||
void
|
||||
|
Loading…
Reference in New Issue
Block a user