summaryrefslogtreecommitdiff
path: root/sed
diff options
context:
space:
mode:
authorPaolo Bonzini <bonzini@gnu.org>2006-12-22 12:38:39 +0000
committerPaolo Bonzini <bonzini@gnu.org>2008-01-09 16:12:24 +0100
commit318f4cd2470bd13a17c2f021406b39e12adf097e (patch)
treeec2bb22013f17ec8b4d1ed061d5d93427575d5a5 /sed
parentd7df092736733fd9d1f28c1731dc17535d23ec9d (diff)
downloadsed-318f4cd2470bd13a17c2f021406b39e12adf097e.tar.gz
portability fixes from Bruno Haible
2006-12-22 Bruno Haible <bruno@clisp.org> * sed/utils.c: Include pathmax. * sed/mbcs.c: Use local_charset. * sed/execute.c: Copy with padding after the mbstate_t member. git-archimport-id: bonzini@gnu.org--2004b/sed--stable--4.1--patch-90
Diffstat (limited to 'sed')
-rw-r--r--sed/execute.c3
-rw-r--r--sed/mbcs.c24
-rw-r--r--sed/utils.c1
3 files changed, 7 insertions, 21 deletions
diff --git a/sed/execute.c b/sed/execute.c
index baf233f..469242b 100644
--- a/sed/execute.c
+++ b/sed/execute.c
@@ -22,6 +22,7 @@
#include "sed.h"
+#include <stddef.h>
#include <stdio.h>
#include <ctype.h>
@@ -86,7 +87,7 @@ struct line {
};
#ifdef HAVE_MBRTOWC
-#define SIZEOF_LINE (sizeof (struct line) - sizeof (mbstate_t))
+#define SIZEOF_LINE offsetof (struct line, mbstate)
#else
#define SIZEOF_LINE (sizeof (struct line))
#endif
diff --git a/sed/mbcs.c b/sed/mbcs.c
index a75472a..47a1c78 100644
--- a/sed/mbcs.c
+++ b/sed/mbcs.c
@@ -1,5 +1,5 @@
/* GNU SED, a batch stream editor.
- Copyright (C) 2003 Free Software Foundation, Inc.
+ Copyright (C) 2003, 2006 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -19,9 +19,7 @@
#include <stdlib.h>
#include <string.h>
-#ifdef HAVE_LANGINFO_CODESET
-#include <langinfo.h>
-#endif
+#include "localcharset.h"
int mb_cur_max;
bool is_utf8;
@@ -56,22 +54,8 @@ initialize_mbcs ()
/* For UTF-8, we know that the encoding is stateless. */
const char *codeset_name;
-#ifdef HAVE_LANGINFO_CODESET
- codeset_name = nl_langinfo (CODESET);
-#else
- codeset_name = getenv ("LC_ALL");
- if (codeset_name == NULL || codeset_name[0] == '\0')
- codeset_name = getenv ("LC_CTYPE");
- if (codeset_name == NULL || codeset_name[0] == '\0')
- codeset_name = getenv ("LANG");
- if (codeset_name == NULL)
- codeset_name = "";
- else if (strchr (codeset_name, '.') != NULL)
- codeset_name = strchr (codeset_name, '.') + 1;
-#endif
-
- is_utf8 = (strcasecmp (codeset_name, "UTF-8") == 0
- || strcasecmp (codeset_name, "UTF8") == 0);
+ codeset_name = locale_charset ();
+ is_utf8 = (strcmp (codeset_name, "UTF-8") == 0);
#ifdef HAVE_MBRTOWC
mb_cur_max = MB_CUR_MAX;
diff --git a/sed/utils.c b/sed/utils.c
index e0ebd20..82c4c1e 100644
--- a/sed/utils.c
+++ b/sed/utils.c
@@ -41,6 +41,7 @@
#include <limits.h>
#include "utils.h"
+#include "pathmax.h"
const char *myname;