--- yacc.y.orig 2004-10-30 17:17:05.000000000 -0700
+++ yacc.y 2004-10-31 00:03:45.000000000 -0700
@@ -237,7 +237,7 @@
case 'o':
locale_file = optarg;
if ((fp = fopen(locale_file, "w")) == 0)
- err(1, "%s", locale_file);
+ err(1, "%s: fopen", locale_file);
atexit(cleanout);
break;
default:
@@ -250,7 +250,7 @@
break;
case 1:
if (freopen(av[optind], "r", stdin) == 0)
- err(1, "%s", av[optind]);
+ err(1, "%s: freopen", av[optind]);
break;
default:
usage();
@@ -651,10 +651,8 @@
/*
* PART 1: The _RuneLocale structure
*/
- if (fwrite((char *)&new_locale, sizeof(new_locale), 1, fp) != 1) {
- perror(locale_file);
- exit(1);
- }
+ if (fwrite((char *)&new_locale, sizeof(new_locale), 1, fp) != 1)
+ err(1, "%s: _RuneLocale structure", locale_file);
/*
* PART 2: The runetype_ext structures (not the actual tables)
*/
@@ -667,10 +665,8 @@
re.__max = htonl(list->max);
re.__map = htonl(list->map);
- if (fwrite((char *)&re, sizeof(re), 1, fp) != 1) {
- perror(locale_file);
- exit(1);
- }
+ if (fwrite((char *)&re, sizeof(re), 1, fp) != 1)
+ err(1, "%s: runetype_ext structures", locale_file);
list = list->next;
}
@@ -686,10 +682,8 @@
re.__max = htonl(list->max);
re.__map = htonl(list->map);
- if (fwrite((char *)&re, sizeof(re), 1, fp) != 1) {
- perror(locale_file);
- exit(1);
- }
+ if (fwrite((char *)&re, sizeof(re), 1, fp) != 1)
+ err(1, "%s: maplower_ext structures", locale_file);
list = list->next;
}
@@ -705,10 +699,8 @@
re.__max = htonl(list->max);
re.__map = htonl(list->map);
- if (fwrite((char *)&re, sizeof(re), 1, fp) != 1) {
- perror(locale_file);
- exit(1);
- }
+ if (fwrite((char *)&re, sizeof(re), 1, fp) != 1)
+ err(1, "%s: mapupper_ext structures", locale_file);
list = list->next;
}
@@ -724,25 +716,20 @@
if (!list->map) {
if (fwrite((char *)list->types,
(list->max - list->min + 1) * sizeof(unsigned long),
- 1, fp) != 1) {
- perror(locale_file);
- exit(1);
- }
+ 1, fp) != 1)
+ err(1, "%s: runetype_ext tables", locale_file);
}
list = list->next;
}
/*
* PART 5: And finally the variable data
+ * SUSv3 says fwrite returns zero when either size of nitems is zero.
*/
- if (fwrite((char *)new_locale.__variable,
- ntohl(new_locale.__variable_len), 1, fp) != 1) {
- perror(locale_file);
- exit(1);
- }
- if (fclose(fp) != 0) {
- perror(locale_file);
- exit(1);
- }
+ if (ntohl(new_locale.__variable_len) > 0 && fwrite((char *)new_locale.__variable,
+ ntohl(new_locale.__variable_len), 1, fp) != 1)
+ err(1, "%s: variable data", locale_file);
+ if (fclose(fp) != 0)
+ err(1, "%s: fclose", locale_file);
fp = NULL;
if (!debug)