diff options
| author | Jim Blandy | 1991-07-15 11:14:59 +0000 |
|---|---|---|
| committer | Jim Blandy | 1991-07-15 11:14:59 +0000 |
| commit | 52b14ac064d4613ead76fc962bda213a659bb140 (patch) | |
| tree | 8dacfcf24a19249ce0f6d0278c5e215b301a8ac6 /src/editfns.c | |
| parent | 38010d507a311f3ff9fb780683ef2cc6e0ea8fc6 (diff) | |
| download | emacs-52b14ac064d4613ead76fc962bda213a659bb140.tar.gz emacs-52b14ac064d4613ead76fc962bda213a659bb140.zip | |
*** empty log message ***
Diffstat (limited to 'src/editfns.c')
| -rw-r--r-- | src/editfns.c | 49 |
1 files changed, 28 insertions, 21 deletions
diff --git a/src/editfns.c b/src/editfns.c index c79f75e4ce7..efdf7f74e8d 100644 --- a/src/editfns.c +++ b/src/editfns.c | |||
| @@ -45,7 +45,7 @@ Lisp_Object Vuser_name; /* user name from USER or LOGNAME. */ | |||
| 45 | void | 45 | void |
| 46 | init_editfns () | 46 | init_editfns () |
| 47 | { | 47 | { |
| 48 | unsigned char *user_name; | 48 | char *user_name; |
| 49 | register unsigned char *p, *q, *r; | 49 | register unsigned char *p, *q, *r; |
| 50 | struct passwd *pw; /* password entry for the current user */ | 50 | struct passwd *pw; /* password entry for the current user */ |
| 51 | extern char *index (); | 51 | extern char *index (); |
| @@ -71,17 +71,23 @@ init_editfns () | |||
| 71 | pw = (struct passwd *) getpwuid (getuid ()); | 71 | pw = (struct passwd *) getpwuid (getuid ()); |
| 72 | Vuser_real_name = build_string (pw ? pw->pw_name : "unknown"); | 72 | Vuser_real_name = build_string (pw ? pw->pw_name : "unknown"); |
| 73 | 73 | ||
| 74 | user_name = (unsigned char *) getenv ("USER"); | 74 | /* Get the effective user name, by consulting environment variables, |
| 75 | or the effective uid if those are unset. */ | ||
| 76 | user_name = (char *) getenv ("USER"); | ||
| 75 | if (!user_name) | 77 | if (!user_name) |
| 76 | user_name = (unsigned char *) getenv ("LOGNAME"); | 78 | user_name = (char *) getenv ("LOGNAME"); |
| 77 | if (user_name) | 79 | if (!user_name) |
| 78 | Vuser_name = build_string (user_name); | 80 | { |
| 79 | else | 81 | pw = (struct passwd *) getpwuid (geteuid ()); |
| 80 | Vuser_name = Vuser_real_name; | 82 | user_name = (char *) (pw ? pw->pw_name : "unknown"); |
| 83 | } | ||
| 84 | Vuser_name = build_string (user_name); | ||
| 81 | 85 | ||
| 86 | /* If the user name claimed in the environment vars differs from | ||
| 87 | the real uid, use the claimed name to find the full name. */ | ||
| 82 | tem = Fstring_equal (Vuser_name, Vuser_real_name); | 88 | tem = Fstring_equal (Vuser_name, Vuser_real_name); |
| 83 | if (!NULL (tem)) | 89 | if (NULL (tem)) |
| 84 | pw = (struct passwd *) getpwnam (user_name); | 90 | pw = (struct passwd *) getpwnam (XSTRING (Vuser_name)->data); |
| 85 | 91 | ||
| 86 | p = (unsigned char *) (pw ? USER_FULL_NAME : "unknown"); | 92 | p = (unsigned char *) (pw ? USER_FULL_NAME : "unknown"); |
| 87 | q = (unsigned char *) index (p, ','); | 93 | q = (unsigned char *) index (p, ','); |
| @@ -96,7 +102,7 @@ init_editfns () | |||
| 96 | r = (char *) alloca (strlen (p) + XSTRING (Vuser_name)->size + 1); | 102 | r = (char *) alloca (strlen (p) + XSTRING (Vuser_name)->size + 1); |
| 97 | bcopy (p, r, q - p); | 103 | bcopy (p, r, q - p); |
| 98 | r[q - p] = 0; | 104 | r[q - p] = 0; |
| 99 | strcat (r, XSTRING (user_name)->data); | 105 | strcat (r, XSTRING (Vuser_name)->data); |
| 100 | r[q - p] = UPCASE (r[q - p]); | 106 | r[q - p] = UPCASE (r[q - p]); |
| 101 | strcat (r, q + 1); | 107 | strcat (r, q + 1); |
| 102 | Vuser_full_name = build_string (r); | 108 | Vuser_full_name = build_string (r); |
| @@ -538,6 +544,12 @@ insert1 (arg) | |||
| 538 | Finsert (1, &arg); | 544 | Finsert (1, &arg); |
| 539 | } | 545 | } |
| 540 | 546 | ||
| 547 | |||
| 548 | /* Callers passing one argument to Finsert need not gcpro the | ||
| 549 | argument "array", since the only element of the array will | ||
| 550 | not be used after calling insert or insert_from_string, so | ||
| 551 | we don't care if it gets trashed. */ | ||
| 552 | |||
| 541 | DEFUN ("insert", Finsert, Sinsert, 0, MANY, 0, | 553 | DEFUN ("insert", Finsert, Sinsert, 0, MANY, 0, |
| 542 | "Insert the arguments, either strings or characters, at point.\n\ | 554 | "Insert the arguments, either strings or characters, at point.\n\ |
| 543 | Point moves forward so that it ends up after the inserted text.\n\ | 555 | Point moves forward so that it ends up after the inserted text.\n\ |
| @@ -549,10 +561,6 @@ Any other markers at the point of insertion remain before the text.") | |||
| 549 | register int argnum; | 561 | register int argnum; |
| 550 | register Lisp_Object tem; | 562 | register Lisp_Object tem; |
| 551 | char str[1]; | 563 | char str[1]; |
| 552 | struct gcpro gcpro1; | ||
| 553 | |||
| 554 | GCPRO1 (*args); | ||
| 555 | gcpro1.nvars = nargs; | ||
| 556 | 564 | ||
| 557 | for (argnum = 0; argnum < nargs; argnum++) | 565 | for (argnum = 0; argnum < nargs; argnum++) |
| 558 | { | 566 | { |
| @@ -574,7 +582,6 @@ Any other markers at the point of insertion remain before the text.") | |||
| 574 | } | 582 | } |
| 575 | } | 583 | } |
| 576 | 584 | ||
| 577 | UNGCPRO; | ||
| 578 | return Qnil; | 585 | return Qnil; |
| 579 | } | 586 | } |
| 580 | 587 | ||
| @@ -589,10 +596,6 @@ Any other markers at the point of insertion also end up after the text.") | |||
| 589 | register int argnum; | 596 | register int argnum; |
| 590 | register Lisp_Object tem; | 597 | register Lisp_Object tem; |
| 591 | char str[1]; | 598 | char str[1]; |
| 592 | struct gcpro gcpro1; | ||
| 593 | |||
| 594 | GCPRO1 (*args); | ||
| 595 | gcpro1.nvars = nargs; | ||
| 596 | 599 | ||
| 597 | for (argnum = 0; argnum < nargs; argnum++) | 600 | for (argnum = 0; argnum < nargs; argnum++) |
| 598 | { | 601 | { |
| @@ -614,7 +617,6 @@ Any other markers at the point of insertion also end up after the text.") | |||
| 614 | } | 617 | } |
| 615 | } | 618 | } |
| 616 | 619 | ||
| 617 | UNGCPRO; | ||
| 618 | return Qnil; | 620 | return Qnil; |
| 619 | } | 621 | } |
| 620 | 622 | ||
| @@ -858,6 +860,8 @@ This allows the buffer's full text to be seen and edited.") | |||
| 858 | BEGV = BEG; | 860 | BEGV = BEG; |
| 859 | SET_BUF_ZV (current_buffer, Z); | 861 | SET_BUF_ZV (current_buffer, Z); |
| 860 | clip_changed = 1; | 862 | clip_changed = 1; |
| 863 | /* Changing the buffer bounds invalidates any recorded current column. */ | ||
| 864 | invalidate_current_column (); | ||
| 861 | return Qnil; | 865 | return Qnil; |
| 862 | } | 866 | } |
| 863 | 867 | ||
| @@ -895,6 +899,8 @@ or markers) bounding the text that should remain visible.") | |||
| 895 | if (point > XFASTINT (e)) | 899 | if (point > XFASTINT (e)) |
| 896 | SET_PT (XFASTINT (e)); | 900 | SET_PT (XFASTINT (e)); |
| 897 | clip_changed = 1; | 901 | clip_changed = 1; |
| 902 | /* Changing the buffer bounds invalidates any recorded current column. */ | ||
| 903 | invalidate_current_column (); | ||
| 898 | return Qnil; | 904 | return Qnil; |
| 899 | } | 905 | } |
| 900 | 906 | ||
| @@ -1007,7 +1013,8 @@ It may contain %-sequences meaning to substitute the next argument.\n\ | |||
| 1007 | %d means print as number in decimal (%o octal, %x hex).\n\ | 1013 | %d means print as number in decimal (%o octal, %x hex).\n\ |
| 1008 | %c means print a number as a single character.\n\ | 1014 | %c means print a number as a single character.\n\ |
| 1009 | %S means print any object as an s-expression (using prin1).\n\ | 1015 | %S means print any object as an s-expression (using prin1).\n\ |
| 1010 | The argument used for %d, %o, %x or %c must be a number.") | 1016 | The argument used for %d, %o, %x or %c must be a number.\n\ |
| 1017 | Use %% to put a single % into the output.") | ||
| 1011 | (nargs, args) | 1018 | (nargs, args) |
| 1012 | int nargs; | 1019 | int nargs; |
| 1013 | register Lisp_Object *args; | 1020 | register Lisp_Object *args; |