- Timestamp:
- Jan 29, 2022 3:00:40 AM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/sed/sed/sed.c
r2660 r3554 117 117 specify the desired line-wrap length for the `l' command\n")); 118 118 #ifndef CONFIG_WITHOUT_O_LANG_C 119 fprintf(out, _(" --codepage=N\n\ 120 switches the locale to the given codepage, affecting how\n\ 121 input files are treated and outputted\n\ 122 windows only, ignored elsewhere\n")); 123 # if _MSC_VER >= 1900 124 fprintf(out, _(" --utf8\n\ 125 alias for --codepage=.UTF-8\n")); 126 # endif 119 127 fprintf(out, _(" --lang_c\n\ 120 128 specify C locale\n")); … … 183 191 #ifndef CONFIG_WITHOUT_O_LANG_C 184 192 {"lang_c", 0, NULL, 'L'}, 193 {"codepage", 1, NULL, 305}, 194 {"utf8", 0, NULL, 306}, 185 195 #endif 186 196 {"quiet", 0, NULL, 'n'}, … … 205 215 int return_code; 206 216 const char *cols = getenv("COLS"); 217 #ifdef KBUILD_OS_WINDOWS 218 const char *locale; 219 #endif 207 220 208 221 initialize_main (&argc, &argv); … … 211 224 #endif 212 225 #if HAVE_SETLOCALE 213 /* Set locale according to user's wishes. */ 214 #ifdef _MSC_VER 215 { 216 /* The redmond guys doesn't listen to the user in the same way... */ 217 const char *lc_all = getenv ("LC_ALL"); 218 if (lc_all) 219 setlocale (LC_ALL, lc_all); 220 else 221 { 222 const char *lc_lang = getenv ("LANG"); 223 const char *lc_ctype = getenv ("LC_TYPE"); 224 const char *lc_collate = getenv ("LC_COLLATE"); 225 226 setlocale (LC_ALL, lc_lang ? lc_lang : ""); 227 if (lc_ctype) 228 setlocale (LC_CTYPE, lc_ctype ? lc_ctype : ""); 229 if (lc_collate) 230 setlocale (LC_COLLATE, lc_collate ? lc_collate : ""); 231 } 232 } 233 #else 226 # ifdef KBUILD_OS_WINDOWS 227 locale = setlocale (LC_ALL, ""); 228 if (getenv("KMK_SED_CODEPAGE_DEBUG")) 229 fprintf (stderr, "kmk_sed: codepage=%u locale=%s ACP=%u\n", 230 get_crt_codepage(), locale, get_ansi_codepage()); 231 # else 234 232 setlocale (LC_ALL, ""); 235 # endif233 # endif 236 234 #endif 237 235 initialize_mbcs (); … … 299 297 #ifndef CONFIG_WITHOUT_O_LANG_C 300 298 case 'L': 301 setlocale (LC_ALL, "C"); 299 locale = setlocale (LC_ALL, "C"); 300 if (getenv("KMK_SED_CODEPAGE_DEBUG")) 301 fprintf (stderr, "kmk_sed: codepage=%u locale=%s ACP=%u\n", 302 get_crt_codepage(), locale, get_ansi_codepage()); 302 303 initialize_mbcs (); 303 304 # if ENABLE_NLS … … 306 307 # endif 307 308 break; 309 310 case 306: /* --codepage=N */ 311 # if _MSC_VER < 1900 312 break; /* does not work, so ignore */ 313 # else 314 optarg = ".UTF-8"; 315 # endif 316 /* fall through */ 317 case 305: /* --codepage=N */ 318 { 319 # ifdef KBUILD_OS_WINDOWS 320 char szTmp[64]; 321 if (optarg[0] != '.') 322 optarg = strncat (strcpy (szTmp, "."), optarg, sizeof (szTmp) - 1); 323 locale = setlocale (LC_ALL, optarg); 324 if (locale == NULL) 325 fprintf (stderr, 326 _("%s: warning: setlocale (LC_ALL, \"%s\") failed: %d\n"), 327 myname, optarg, errno); 328 else if (getenv("KMK_SED_CODEPAGE_DEBUG")) 329 fprintf (stderr, "kmk_sed: codepage=%u locale=%s ACP=%u\n", 330 get_crt_codepage(), locale, get_ansi_codepage()); 331 initialize_mbcs(); 332 # if ENABLE_NLS 333 bindtextdomain (PACKAGE, LOCALEDIR); 334 textdomain (PACKAGE); 335 # endif 336 # endif 337 break; 338 } 308 339 #endif 309 340
Note:
See TracChangeset
for help on using the changeset viewer.