summaryrefslogtreecommitdiff
path: root/usr/src
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src')
-rw-r--r--usr/src/cmd/msgfmt/msgfmt.c58
-rw-r--r--usr/src/cmd/msgfmt/xgettext.c127
2 files changed, 89 insertions, 96 deletions
diff --git a/usr/src/cmd/msgfmt/msgfmt.c b/usr/src/cmd/msgfmt/msgfmt.c
index e6d4b01df4..b8896c54c0 100644
--- a/usr/src/cmd/msgfmt/msgfmt.c
+++ b/usr/src/cmd/msgfmt/msgfmt.c
@@ -24,8 +24,6 @@
* Use is subject to license terms.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
#include "sun_msgfmt.h"
static void read_psffm(char *);
@@ -294,7 +292,7 @@ read_psffm(char *file)
* Process MSGID Tokens.
*/
token_found = (wcsncmp(MSGID_TOKEN, linebufptr,
- MSGID_LEN) == 0) ? 1 : 0;
+ MSGID_LEN) == 0) ? 1 : 0;
if (token_found || (quotefound && inmsgid)) {
@@ -329,7 +327,7 @@ read_psffm(char *file)
msgid_linenum = linenum;
p = linebufptr;
linebufptr = consume_whitespace(
- linebufptr + MSGID_LEN);
+ linebufptr + MSGID_LEN);
ln_size -= linebufptr - p;
bufptr = gmsgid;
bufptr_index = 0;
@@ -345,7 +343,7 @@ read_psffm(char *file)
* Process MSGSTR Tokens.
*/
token_found = (wcsncmp(MSGSTR_TOKEN, linebufptr,
- MSGSTR_LEN) == 0) ? 1 : 0;
+ MSGSTR_LEN) == 0) ? 1 : 0;
if (token_found || (quotefound && inmsgstr)) {
if (token_found) {
@@ -374,7 +372,7 @@ read_psffm(char *file)
msgstr_linenum = linenum;
p = linebufptr;
linebufptr = consume_whitespace(
- linebufptr + MSGSTR_LEN);
+ linebufptr + MSGSTR_LEN);
ln_size -= linebufptr - p;
bufptr = gmsgstr;
bufptr_index = 0;
@@ -392,7 +390,7 @@ read_psffm(char *file)
* if msgstr was processed last time.
*/
token_found = (wcsncmp(DOMAIN_TOKEN, linebufptr,
- DOMAIN_LEN) == 0) ? 1 : 0;
+ DOMAIN_LEN) == 0) ? 1 : 0;
if ((token_found) || (quotefound && indomain)) {
if (token_found) {
if (!CK_NXT_CH(linebufptr, DOMAIN_LEN+1)) {
@@ -423,9 +421,9 @@ read_psffm(char *file)
} else {
p = linebufptr;
linebufptr = consume_whitespace(
- linebufptr + DOMAIN_LEN);
+ linebufptr + DOMAIN_LEN);
(void) memset(gcurrent_domain, 0,
- sizeof (gcurrent_domain));
+ sizeof (gcurrent_domain));
ln_size -= linebufptr - p;
bufptr = gcurrent_domain;
bufptr_index = 0;
@@ -463,14 +461,14 @@ load_buffer:
if (bufptr == gmsgid) {
if (gmsgid_size < (bufptr_index + ll)) {
gmsgid = (char *)Xrealloc(gmsgid,
- bufptr_index + ll);
+ bufptr_index + ll);
bufptr = gmsgid;
gmsgid_size = bufptr_index + ll;
}
} else if (bufptr == gmsgstr) {
if (gmsgstr_size < (bufptr_index + ll)) {
gmsgstr = (char *)Xrealloc(gmsgstr,
- bufptr_index + ll);
+ bufptr_index + ll);
bufptr = gmsgstr;
gmsgstr_size = bufptr_index + ll;
}
@@ -489,7 +487,7 @@ warning(gettext(WARN_MISSING_QUOTE_AT_EOL), linenum);
break;
case L'\\':
- if ((mb = expand_meta(&linebufptr)) != NULL)
+ if ((mb = expand_meta(&linebufptr)) != '\0')
bufptr[bufptr_index++] = mb;
break;
@@ -505,7 +503,7 @@ warning(gettext(WARN_MISSING_QUOTE_AT_EOL), linenum);
linebufptr = consume_whitespace(linebufptr);
if (*linebufptr != L'\n') {
warning(gettext(WARN_INVALID_STRING),
- linenum);
+ linenum);
}
break;
}
@@ -626,7 +624,7 @@ expand_meta(wchar_t **buf)
}
return (n);
default:
- return (NULL);
+ return ('\0');
}
} /* expand_meta */
@@ -642,8 +640,8 @@ sortit(char *msgid, char *msgstr)
#ifdef DEBUG
(void) fprintf(stderr,
- "==> sortit(), domain=<%s> msgid=<%s> msgstr=<%s>\n",
- gcurrent_domain, msgid, msgstr);
+ "==> sortit(), domain=<%s> msgid=<%s> msgstr=<%s>\n",
+ gcurrent_domain, msgid, msgstr);
#endif
/*
@@ -666,7 +664,7 @@ sortit(char *msgid, char *msgstr)
*/
static void
insert_message(struct domain_struct *dom,
- char *msgid, char *msgstr)
+ char *msgid, char *msgstr)
{
struct msg_chain *p1;
struct msg_chain *node, *prev_node;
@@ -684,7 +682,7 @@ insert_message(struct domain_struct *dom,
if (b == 0) {
if (verbose)
warning(gettext(WARN_DUP_MSG),
- msgid, msgid_linenum);
+ msgid, msgid_linenum);
return;
} else if (b > 0) { /* to implement descending order */
p1 = dom->first_elem;
@@ -705,7 +703,7 @@ insert_message(struct domain_struct *dom,
if (b == 0) {
if (verbose)
warning(gettext(WARN_DUP_MSG),
- msgid, msgid_linenum);
+ msgid, msgid_linenum);
return;
} else if (b < 0) { /* to implement descending order */
/* move to the next node */
@@ -714,7 +712,7 @@ insert_message(struct domain_struct *dom,
} else {
/* insert a new msg node */
node = (struct msg_chain *)
- Xmalloc(sizeof (struct msg_chain));
+ Xmalloc(sizeof (struct msg_chain));
node->next = p1;
node->msgid = Xstrdup(msgid);
node->msgstr = Xstrdup(msgstr);
@@ -735,7 +733,7 @@ insert_message(struct domain_struct *dom,
* Therefore, append it.
*/
node = (struct msg_chain *)
- Xmalloc(sizeof (struct msg_chain));
+ Xmalloc(sizeof (struct msg_chain));
node->next = NULL;
node->msgid = Xstrdup(msgid);
node->msgstr = Xstrdup(msgstr);
@@ -795,7 +793,7 @@ find_domain_node(char *domain_name)
} else {
/* insert a new domain node */
node = (struct domain_struct *)
- Xmalloc(sizeof (struct domain_struct));
+ Xmalloc(sizeof (struct domain_struct));
node->next = p1;
node->domain = Xstrdup(domain_name);
node->first_elem = NULL;
@@ -817,7 +815,7 @@ find_domain_node(char *domain_name)
* list is empty.
*/
node = (struct domain_struct *)
- Xmalloc(sizeof (struct domain_struct));
+ Xmalloc(sizeof (struct domain_struct));
node->next = NULL;
node->domain = Xstrdup(domain_name);
node->first_elem = NULL;
@@ -864,7 +862,7 @@ binary_compute(int i, int j, int *more, int *less)
static void
output_all_mo_files(void)
{
- struct domain_struct *p;
+ struct domain_struct *p;
p = first_domain;
while (p) {
@@ -943,8 +941,8 @@ output_one_mo_file(struct domain_struct *dom)
int i;
for (i = 0; i < message_count; i++) {
(void) fprintf(stderr,
- " less[%2d]=%2d, more[%2d]=%2d\n",
- i, less[i], i, more[i]);
+ " less[%2d]=%2d, more[%2d]=%2d\n",
+ i, less[i], i, more[i]);
}
}
#endif
@@ -1068,7 +1066,7 @@ _mbsntowcs(wchar_t **bufhead, char **mbuf, size_t *fsize)
*/
ttbufsize = tbufsize + 2;
th = (wchar_t *)Xrealloc(th,
- sizeof (wchar_t) * ttbufsize);
+ sizeof (wchar_t) * ttbufsize);
tp = th + tbufsize - nc;
tbufsize = ttbufsize;
}
@@ -1083,7 +1081,7 @@ _mbsntowcs(wchar_t **bufhead, char **mbuf, size_t *fsize)
if (nc == 0) {
ttbufsize = tbufsize + LINE_SIZE;
th = (wchar_t *)Xrealloc(th,
- sizeof (wchar_t) * ttbufsize);
+ sizeof (wchar_t) * ttbufsize);
tp = th + tbufsize;
nc = LINE_SIZE;
tbufsize = ttbufsize;
@@ -1107,7 +1105,7 @@ _mbsntowcs(wchar_t **bufhead, char **mbuf, size_t *fsize)
*/
ttbufsize = tbufsize + 2;
th = (wchar_t *)Xrealloc(th,
- sizeof (wchar_t) * ttbufsize);
+ sizeof (wchar_t) * ttbufsize);
tp = th + tbufsize - nc;
tbufsize = ttbufsize;
}
@@ -1136,7 +1134,7 @@ printlist(void)
m = p->first_elem;
while (m) {
(void) fprintf(stderr, " msgid=<%s>, msgstr=<%s>\n",
- m->msgid, m->msgstr);
+ m->msgid, m->msgstr);
m = m->next;
}
p = p->next;
diff --git a/usr/src/cmd/msgfmt/xgettext.c b/usr/src/cmd/msgfmt/xgettext.c
index 8b91a2a842..c2f55d81c6 100644
--- a/usr/src/cmd/msgfmt/xgettext.c
+++ b/usr/src/cmd/msgfmt/xgettext.c
@@ -24,7 +24,6 @@
* All rights reserved.
* Use is subject to license terms.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
#include <ctype.h>
#include <stdio.h>
@@ -58,13 +57,13 @@ struct strlist_st {
/*
* istextdomain : Boolean telling if this node contains textdomain call.
- * isduplicate : Boolean telling if this node duplicate of any other msgid.
+ * isduplicate : Boolean telling if this node duplicate of any other msgid.
* msgid : contains msgid or textdomain if istextdomain is true.
* msgstr : contains msgstr.
* comment : comment extracted in case of -c option.
* fname : tells which file contains msgid.
* linenum : line number in the file.
- * next : Next node.
+ * next : Next node.
*/
struct element_st {
char istextdomain;
@@ -409,30 +408,28 @@ static void
print_help(void)
{
(void) fprintf(stderr, "\n");
+ (void) fprintf(stderr, "-a\t\t\tfind ALL strings\n");
(void) fprintf(stderr,
- "-a\t\t\tfind ALL strings\n");
+ "-c <comment-tag>\tget comments containing <flag>\n");
(void) fprintf(stderr,
- "-c <comment-tag>\tget comments containing <flag>\n");
+ "-d <default-domain>\tuse <default-domain> for default domain\n");
+ (void) fprintf(stderr, "-h\t\t\tHelp\n");
(void) fprintf(stderr,
- "-d <default-domain>\tuse <default-domain> for default domain\n");
+ "-j\t\t\tupdate existing file with the current result\n");
(void) fprintf(stderr,
- "-h\t\t\tHelp\n");
+ "-M <suffix>\t\tfill in msgstr with msgid<suffix>\n");
(void) fprintf(stderr,
- "-j\t\t\tupdate existing file with the current result\n");
+ "-m <prefix>\t\tfill in msgstr with <prefix>msgid\n");
(void) fprintf(stderr,
- "-M <suffix>\t\tfill in msgstr with msgid<suffix>\n");
+ "-n\t\t\tline# file name and line number info in output\n");
(void) fprintf(stderr,
- "-m <prefix>\t\tfill in msgstr with <prefix>msgid\n");
+ "-p <pathname>\t\tuse <pathname> for output file directory\n");
(void) fprintf(stderr,
- "-n\t\t\tline# file name and line number info in output\n");
+ "-s\t\t\tgenerate sorted output files\n");
+ (void) fprintf(stderr, "-x <exclude-file>\texclude strings in file "
+ "<exclude-file> from output\n");
(void) fprintf(stderr,
- "-p <pathname>\t\tuse <pathname> for output file directory\n");
- (void) fprintf(stderr,
- "-s\t\t\tgenerate sorted output files\n");
- (void) fprintf(stderr,
-"-x <exclude-file>\texclude strings in file <exclude-file> from output\n");
- (void) fprintf(stderr,
- "-\t\t\tread stdin, use as a filter (input only)\n");
+ "-\t\t\tread stdin, use as a filter (input only)\n");
} /* print_help */
/*
@@ -521,7 +518,7 @@ handle_cplus_comment_line(void)
if (in_quote == TRUE) {
lstrcat(qstring_buf, yytext);
} else if ((in_comment == FALSE) &&
- (in_skippable_string == FALSE)) {
+ (in_skippable_string == FALSE)) {
/*
* If already in c comments, don't do anything.
@@ -546,7 +543,7 @@ handle_open_comment(void)
if (in_quote == TRUE) {
lstrcat(qstring_buf, yytext);
} else if ((in_comment == FALSE) &&
- (in_skippable_string == FALSE)) {
+ (in_skippable_string == FALSE)) {
in_comment = TRUE;
is_last_comment_line = FALSE;
@@ -604,7 +601,7 @@ handle_gettext(void)
* gettext will be put into default domain .po file
* curr_domain does not change for gettext.
*/
- curr_domain[0] = NULL;
+ curr_domain[0] = '\0';
}
} /* handle_gettext */
@@ -636,7 +633,7 @@ handle_dgettext(void)
* dgettext will be put into domain file specified.
* curr_domain will follow.
*/
- curr_domain[0] = NULL;
+ curr_domain[0] = '\0';
}
} /* handle_dgettext */
@@ -669,7 +666,7 @@ handle_dcgettext(void)
* dcgettext will be put into domain file specified.
* curr_domain will follow.
*/
- curr_domain[0] = NULL;
+ curr_domain[0] = '\0';
}
} /* handle_dcgettext */
@@ -687,7 +684,7 @@ handle_textdomain(void)
} else if (in_comment == FALSE) {
in_textdomain = TRUE;
linenum_saved = curr_linenum;
- curr_domain[0] = NULL;
+ curr_domain[0] = '\0';
}
} /* handle_textdomain */
@@ -774,7 +771,7 @@ handle_esc_newline(void)
}
}
- curr_line[0] = NULL;
+ curr_line[0] = '\0';
} /* handle_esc_newline */
/*
@@ -789,9 +786,9 @@ handle_quote(void)
if (in_comment == TRUE) {
/*EMPTY*/
} else if ((in_gettext == TRUE) ||
- (in_dgettext == TRUE) ||
- (in_dcgettext == TRUE) ||
- (in_textdomain == TRUE)) {
+ (in_dgettext == TRUE) ||
+ (in_dcgettext == TRUE) ||
+ (in_textdomain == TRUE)) {
if (in_str == TRUE) {
if (in_quote == FALSE) {
in_quote = TRUE;
@@ -821,7 +818,7 @@ handle_quote(void)
}
} else {
in_skippable_string = (in_skippable_string == TRUE) ?
- FALSE : TRUE;
+ FALSE : TRUE;
}
} /* handle_quote */
@@ -847,7 +844,7 @@ copy_strlist_to_str(char *str, struct strlist_st *strlist)
{
struct strlist_st *p;
- str[0] = NULL;
+ str[0] = '\0';
if (strlist != NULL) {
p = strlist;
@@ -883,7 +880,7 @@ handle_comma(void)
*/
if (is_first_comma_found == FALSE) {
copy_strlist_to_str(curr_domain,
- strhead);
+ strhead);
free_strlist(strhead);
strhead = strtail = NULL;
is_first_comma_found = TRUE;
@@ -936,7 +933,7 @@ handle_newline(void)
}
}
- curr_line[0] = NULL;
+ curr_line[0] = '\0';
/*
* C++ comment always ends with new line.
*/
@@ -966,9 +963,9 @@ static void
initialize_globals(void)
{
default_domain = strdup(DEFAULT_DOMAIN);
- curr_domain[0] = NULL;
- curr_file[0] = NULL;
- qstring_buf[0] = NULL;
+ curr_domain[0] = '\0';
+ curr_file[0] = '\0';
+ qstring_buf[0] = '\0';
} /* initialize_globals() */
/*
@@ -1041,7 +1038,7 @@ trim_line(char *line)
for (i = 0; i <= (last-first); i++) {
line[i] = line[p++];
}
- line [i] = NULL;
+ line [i] = '\0';
} /* trim_line */
/*
@@ -1058,7 +1055,7 @@ read_exclude_file(void)
if ((fp = fopen(exclude_file, "r")) == NULL) {
(void) fprintf(stderr, "ERROR, can't open exclude file: %s\n",
- exclude_file);
+ exclude_file);
exit(2);
}
@@ -1144,7 +1141,7 @@ get_next_ch(struct strlist_st *p, int *m, char *c)
break;
} else if (p->str == NULL) {
p = p->next;
- } else if (p->str[*m] == NULL) {
+ } else if (p->str[*m] == '\0') {
p = p->next;
*m = 0;
} else {
@@ -1380,7 +1377,7 @@ add_qstring_to_str(void)
strtail = strtail->next;
}
- qstring_buf[0] = NULL;
+ qstring_buf[0] = '\0';
} /* add_qstring_to_str */
/*
@@ -1403,16 +1400,16 @@ find_domain_node(char *dname)
}
if ((dname == NULL) ||
- (dname[0] == NULL) ||
+ (dname[0] == '\0') ||
(strcmp(dname, default_domain) == 0)) {
if (def_dom == NULL) {
def_dom = new_domain();
}
if (strcmp(dname, default_domain) == 0) {
- (void) fprintf(stderr,
- "%s \"%s\" is used in dgettext of file:%s line:%d.\n",
- "Warning: default domain name",
- default_domain, curr_file, curr_linenum);
+ (void) fprintf(stderr, "%s \"%s\" is used in dgettext "
+ "of file:%s line:%d.\n",
+ "Warning: default domain name",
+ default_domain, curr_file, curr_linenum);
}
return (def_dom);
} else {
@@ -1493,15 +1490,15 @@ isextracted(struct strlist_st *strlist)
p = strlist;
while (p != NULL) {
first = strdup(p->str);
- while ((first != NULL) && (first[0] != NULL)) {
+ while ((first != NULL) && (first[0] != '\0')) {
pc = first;
/*CONSTCOND*/
while (1) {
- if (*pc == NULL) {
+ if (*pc == '\0') {
break;
} else if ((*pc == ' ') || (*pc == '\t')) {
- *pc++ = NULL;
+ *pc++ = '\0';
break;
}
pc++;
@@ -1645,7 +1642,7 @@ add_str_to_element_list(int istextdomain, char *domain_list)
*/
if (tmp_dom != NULL) {
if (isduplicate(tmp_dom->gettext_head,
- tmp_elem->msgid) == TRUE) {
+ tmp_elem->msgid) == TRUE) {
tmp_elem->isduplicate = TRUE;
}
}
@@ -1694,7 +1691,7 @@ write_all_files(void)
*/
static void
add_node_to_polist(struct element_st **pohead,
- struct element_st **potail, struct element_st *elem)
+ struct element_st **potail, struct element_st *elem)
{
if (elem == NULL) {
return;
@@ -1752,7 +1749,7 @@ read_po(char *fname)
state = IN_COMMENT;
tmp_elem = new_element();
tmp_elem->comment = comment_tail =
- new_strlist();
+ new_strlist();
/*
* remove new line and skip "# "
* in the beginning of the existing
@@ -1905,7 +1902,7 @@ write_one_file(struct domain_st *head)
* The domain name is either "messages" or specified by option -d.
* The default domain name is contained in default_domain variable.
*/
- dname[0] = NULL;
+ dname[0] = '\0';
if ((head != NULL) &&
(head->dname != NULL)) {
(void) strcpy(dname, head->dname);
@@ -1939,11 +1936,11 @@ write_one_file(struct domain_st *head)
}
existing_po_list = read_po(fname);
head->gettext_head = append_list(existing_po_list,
- head->gettext_head);
+ head->gettext_head);
#ifdef DEBUG
if (head->dname != NULL) {
printf("===after merge (-j option): <%s>===\n",
- head->dname);
+ head->dname);
} else {
printf("===after merge (-j option): <NULL>===\n");
}
@@ -1954,7 +1951,7 @@ write_one_file(struct domain_st *head)
if ((fp = fopen(fname, "w")) == NULL) {
(void) fprintf(stderr,
- "ERROR, can't open output file: %s\n", fname);
+ "ERROR, can't open output file: %s\n", fname);
exit(2);
}
@@ -1996,7 +1993,7 @@ write_one_file(struct domain_st *head)
* because there are read from exising file.
*/
if (((cflg == TRUE) || (jflg == TRUE)) &&
- (p->istextdomain != TRUE)) {
+ (p->istextdomain != TRUE)) {
output_comment(fp, p->comment);
}
@@ -2011,9 +2008,9 @@ write_one_file(struct domain_st *head)
* should not printed in such case.
*/
if ((nflg == TRUE) && (p->istextdomain == FALSE) &&
- (p->linenum > 0)) {
+ (p->linenum > 0)) {
(void) fprintf(fp, "# File:%s, line:%d\n",
- p->fname, p->linenum);
+ p->fname, p->linenum);
}
/*
@@ -2048,7 +2045,7 @@ output_textdomain(FILE *fp, struct element_st *p)
* Write textdomain() line as a comment.
*/
(void) fprintf(fp, "# File:%s, line:%d, textdomain(\"%s\");\n",
- p->fname, p->linenum, p->msgid->str);
+ p->fname, p->linenum, p->msgid->str);
} /* output_textdomain */
/*
@@ -2113,20 +2110,18 @@ output_msgid(FILE *fp, struct strlist_st *p, int duplicate)
*/
if ((Mflg == TRUE) && (p->next == NULL)) {
/* -M and -m and single line case */
- (void) fprintf(fp,
- "msgstr \"%s%s%s\"\n",
- prefix, p->str, suffix);
+ (void) fprintf(fp, "msgstr \"%s%s%s\"\n",
+ prefix, p->str, suffix);
} else {
/* -M and -m and multi line case */
- (void) fprintf(fp,
- "msgstr \"%s%s\"\n",
- prefix, p->str);
+ (void) fprintf(fp, "msgstr \"%s%s\"\n",
+ prefix, p->str);
}
} else {
if ((Mflg == TRUE) && (p->next == NULL)) {
/* -M only with single line case */
(void) fprintf(fp, "msgstr \"%s%s\"\n",
- p->str, suffix);
+ p->str, suffix);
} else {
/* -M only with multi line case */
(void) fprintf(fp, "msgstr \"%s\"\n", p->str);
@@ -2144,7 +2139,7 @@ output_msgid(FILE *fp, struct strlist_st *p, int duplicate)
* If multi line msgid, add suffix after the last line.
*/
if ((Mflg == TRUE) && (p->next != NULL) &&
- (suffix[0] != NULL)) {
+ (suffix[0] != '\0')) {
(void) fprintf(fp, " \"%s\"\n", suffix);
}
} else {