X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=src%2Feditfns.c;h=a4ee7464eb1d8063689ebfb9a414772ae961a078;hb=975655e6b5b1526ee82b159b3eadf69888c42090;hp=6866beff90c5fff90e10a5f70399fd9c7e92d900;hpb=82da33b61c3e2dd2937db17b75b2838188793053;p=chise%2Fxemacs-chise.git- diff --git a/src/editfns.c b/src/editfns.c index 6866bef..a4ee746 100644 --- a/src/editfns.c +++ b/src/editfns.c @@ -96,7 +96,7 @@ init_editfns (void) if ((p = getenv ("NAME"))) /* I don't think it's the right thing to do the ampersand modification on NAME. Not that it matters anymore... -hniksic */ - Vuser_full_name = build_ext_string (p, FORMAT_OS); + Vuser_full_name = build_ext_string (p, Qnative); else Vuser_full_name = Fuser_full_name (Qnil); } @@ -131,7 +131,7 @@ An empty string will return the constant `nil'. */ (str)) { - struct Lisp_String *p; + Lisp_String *p; CHECK_STRING (str); p = XSTRING (str); @@ -625,7 +625,7 @@ On Unix it is obtained from TMPDIR, with /tmp as the default tmpdir = "/tmp"; #endif - return build_ext_string (tmpdir, FORMAT_FILENAME); + return build_ext_string (tmpdir, Qfile_name); } DEFUN ("user-login-name", Fuser_login_name, 0, 1, 0, /* @@ -764,11 +764,13 @@ value of `user-full-name' is returned. user_name = (STRINGP (user) ? user : Fuser_login_name (user)); if (!NILP (user_name)) /* nil when nonexistent UID passed as arg */ { - CONST char *user_name_ext; + const char *user_name_ext; /* Fuck me. getpwnam() can call select() and (under IRIX at least) things get wedged if a SIGIO arrives during this time. */ - GET_C_STRING_OS_DATA_ALLOCA (user_name, user_name_ext); + TO_EXTERNAL_FORMAT (LISP_STRING, user_name, + C_STRING_ALLOCA, user_name_ext, + Qnative); slow_down_interrupts (); pw = (struct passwd *) getpwnam (user_name_ext); speed_up_interrupts (); @@ -777,16 +779,16 @@ value of `user-full-name' is returned. /* #### - Stig sez: this should return nil instead of "unknown" when pw==0 */ /* Ben sez: bad idea because it's likely to break something */ #ifndef AMPERSAND_FULL_NAME - p = ((pw) ? USER_FULL_NAME : "unknown"); /* don't gettext */ + p = pw ? USER_FULL_NAME : "unknown"; /* don't gettext */ q = strchr (p, ','); #else - p = ((pw) ? USER_FULL_NAME : "unknown"); /* don't gettext */ + p = pw ? USER_FULL_NAME : "unknown"; /* don't gettext */ q = strchr (p, ','); #endif tem = ((!NILP (user) && !pw) ? Qnil : make_ext_string ((Extbyte *) p, (q ? q - p : strlen (p)), - FORMAT_OS)); + Qnative)); #ifdef AMPERSAND_FULL_NAME if (!NILP (tem)) @@ -811,7 +813,7 @@ value of `user-full-name' is returned. return tem; } -static char *cached_home_directory; +static Extbyte *cached_home_directory; void uncache_home_directory (void) @@ -820,29 +822,42 @@ uncache_home_directory (void) of a few bytes */ } +/* !!#### not Mule correct. */ + /* Returns the home directory, in external format */ -char * +Extbyte * get_home_directory (void) { + /* !!#### this is hopelessly bogus. Rule #1: Do not make any assumptions + about what format an external string is in. Could be Unicode, for all + we know, and then all the operations below are totally bogus. + Instead, convert all data to internal format *right* at the juncture + between XEmacs and the outside world, the very moment we first get + the data. --ben */ int output_home_warning = 0; if (cached_home_directory == NULL) { - if ((cached_home_directory = getenv("HOME")) == NULL) + if ((cached_home_directory = (Extbyte *) getenv("HOME")) == NULL) { #if defined(WINDOWSNT) && !defined(__CYGWIN32__) - char *homedrive, *homepath; + char *homedrive, *homepath; if ((homedrive = getenv("HOMEDRIVE")) != NULL && (homepath = getenv("HOMEPATH")) != NULL) { cached_home_directory = - (char *) xmalloc(strlen(homedrive) + strlen(homepath) + 1); - sprintf(cached_home_directory, "%s%s", homedrive, homepath); + (Extbyte *) xmalloc (strlen (homedrive) + + strlen (homepath) + 1); + sprintf((char *) cached_home_directory, "%s%s", + homedrive, + homepath); } else { -# if 1 +# if 0 /* changed by ben. This behavior absolutely stinks, and the + possibility being addressed here occurs quite commonly. + Using the current directory makes absolutely no sense. */ /* * Use the current directory. * This preserves the existing XEmacs behavior, but is different @@ -850,18 +865,18 @@ get_home_directory (void) */ if (initial_directory[0] != '\0') { - cached_home_directory = initial_directory; + cached_home_directory = (Extbyte*) initial_directory; } else { /* This will probably give the wrong value */ - cached_home_directory = getcwd (NULL, 0); + cached_home_directory = (Extbyte*) getcwd (NULL, 0); } # else /* * This is NT Emacs behavior */ - cached_home_directory = "C:\\"; + cached_home_directory = (Extbyte *) "C:\\"; output_home_warning = 1; # endif } @@ -872,7 +887,7 @@ get_home_directory (void) * We probably should try to extract pw_dir from /etc/passwd, * before falling back to this. */ - cached_home_directory = "/"; + cached_home_directory = (Extbyte *) "/"; output_home_warning = 1; #endif /* !WINDOWSNT */ } @@ -895,11 +910,11 @@ Return the user's home directory, as a string. */ ()) { - char *path = get_home_directory (); + Extbyte *path = get_home_directory (); return path == NULL ? Qnil : Fexpand_file_name (Fsubstitute_in_file_name - (build_ext_string (path, FORMAT_FILENAME)), + (build_ext_string ((char *) path, Qfile_name)), Qnil); } @@ -999,9 +1014,9 @@ time_to_lisp (time_t the_time) return Fcons (make_int (item >> 16), make_int (item & 0xffff)); } -size_t emacs_strftime (char *string, size_t max, CONST char *format, - CONST struct tm *tm); -static long difftm (CONST struct tm *a, CONST struct tm *b); +size_t emacs_strftime (char *string, size_t max, const char *format, + const struct tm *tm); +static long difftm (const struct tm *a, const struct tm *b); DEFUN ("format-time-string", Fformat_time_string, 1, 2, 0, /* @@ -1068,10 +1083,10 @@ characters appearing in the day and month names may be incorrect. char *buf = (char *) alloca (size); *buf = 1; if (emacs_strftime (buf, size, - (CONST char *) XSTRING_DATA (format_string), + (const char *) XSTRING_DATA (format_string), localtime (&value)) || !*buf) - return build_ext_string (buf, FORMAT_BINARY); + return build_ext_string (buf, Qbinary); /* If buffer was too small, make it bigger. */ size *= 2; } @@ -1225,14 +1240,14 @@ and from `file-attributes'. strncpy (buf, tem, 24); buf[24] = 0; - return build_ext_string (buf, FORMAT_BINARY); + return build_ext_string (buf, Qbinary); } #define TM_YEAR_ORIGIN 1900 /* Yield A - B, measured in seconds. */ static long -difftm (CONST struct tm *a, CONST struct tm *b) +difftm (const struct tm *a, const struct tm *b) { int ay = a->tm_year + (TM_YEAR_ORIGIN - 1); int by = b->tm_year + (TM_YEAR_ORIGIN - 1); @@ -1819,7 +1834,7 @@ Returns the number of substitutions performed. mc_count = begin_multiple_change (buf, pos, stop); if (STRINGP (table)) { - struct Lisp_String *stable = XSTRING (table); + Lisp_String *stable = XSTRING (table); Charcount size = string_char_length (stable); #ifdef MULE /* Under Mule, string_char(n) is O(n), so for large tables or @@ -1899,7 +1914,7 @@ Returns the number of substitutions performed. && (XCHAR_TABLE_TYPE (table) == CHAR_TABLE_TYPE_GENERIC || XCHAR_TABLE_TYPE (table) == CHAR_TABLE_TYPE_CHAR)) { - struct Lisp_Char_Table *ctable = XCHAR_TABLE (table); + Lisp_Char_Table *ctable = XCHAR_TABLE (table); for (; pos < stop && (oc = BUF_FETCH_CHAR (buf, pos), 1); pos++) {