diff options
| author | Paul Eggert | 2012-09-19 10:28:13 -0700 |
|---|---|---|
| committer | Paul Eggert | 2012-09-19 10:28:13 -0700 |
| commit | 05642592f037ebfda2d71114c5016cc8fd7518eb (patch) | |
| tree | 2a23c8542e287b056d8dc164f239c8d6143972aa /src | |
| parent | 35f5b19d7aa70f09c85478402ed0f7671882fdc4 (diff) | |
| download | emacs-05642592f037ebfda2d71114c5016cc8fd7518eb.tar.gz emacs-05642592f037ebfda2d71114c5016cc8fd7518eb.zip | |
* frame.c (read_integer): Remove. All uses replaced by strtol/strtoul.
(XParseGeometry): Now static. Substitute extremal values for
values that are out of range.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 6 | ||||
| -rw-r--r-- | src/frame.c | 103 |
2 files changed, 35 insertions, 74 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 8c3af794ab1..42e7f6e87a3 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,9 @@ | |||
| 1 | 2012-09-19 Paul Eggert <eggert@cs.ucla.edu> | ||
| 2 | |||
| 3 | * frame.c (read_integer): Remove. All uses replaced by strtol/strtoul. | ||
| 4 | (XParseGeometry): Now static. Substitute extremal values for | ||
| 5 | values that are out of range. | ||
| 6 | |||
| 1 | 2012-09-19 Jan Djärv <jan.h.d@swipnet.se> | 7 | 2012-09-19 Jan Djärv <jan.h.d@swipnet.se> |
| 2 | 8 | ||
| 3 | * w32xfns.c (read_integer, XParseGeometry): Move to frame.c. | 9 | * w32xfns.c (read_integer, XParseGeometry): Move to frame.c. |
diff --git a/src/frame.c b/src/frame.c index 28571310032..f3d16171516 100644 --- a/src/frame.c +++ b/src/frame.c | |||
| @@ -3912,50 +3912,27 @@ x_default_parameter (struct frame *f, Lisp_Object alist, Lisp_Object prop, | |||
| 3912 | */ | 3912 | */ |
| 3913 | 3913 | ||
| 3914 | static int | 3914 | static int |
| 3915 | read_integer (register char *string, char **NextString) | ||
| 3916 | { | ||
| 3917 | register int Result = 0; | ||
| 3918 | int Sign = 1; | ||
| 3919 | |||
| 3920 | if (*string == '+') | ||
| 3921 | string++; | ||
| 3922 | else if (*string == '-') | ||
| 3923 | { | ||
| 3924 | string++; | ||
| 3925 | Sign = -1; | ||
| 3926 | } | ||
| 3927 | for (; (*string >= '0') && (*string <= '9'); string++) | ||
| 3928 | { | ||
| 3929 | Result = (Result * 10) + (*string - '0'); | ||
| 3930 | } | ||
| 3931 | *NextString = string; | ||
| 3932 | if (Sign >= 0) | ||
| 3933 | return (Result); | ||
| 3934 | else | ||
| 3935 | return (-Result); | ||
| 3936 | } | ||
| 3937 | |||
| 3938 | int | ||
| 3939 | XParseGeometry (char *string, | 3915 | XParseGeometry (char *string, |
| 3940 | int *x, int *y, | 3916 | int *x, int *y, |
| 3941 | unsigned int *width, unsigned int *height) | 3917 | unsigned int *width, unsigned int *height) |
| 3942 | { | 3918 | { |
| 3943 | int mask = NoValue; | 3919 | int mask = NoValue; |
| 3944 | register char *strind; | 3920 | char *strind; |
| 3945 | unsigned int tempWidth, tempHeight; | 3921 | unsigned long int tempWidth, tempHeight; |
| 3946 | int tempX, tempY; | 3922 | long int tempX, tempY; |
| 3947 | char *nextCharacter; | 3923 | char *nextCharacter; |
| 3948 | 3924 | ||
| 3949 | if ((string == NULL) || (*string == '\0')) return (mask); | 3925 | if (string == NULL || *string == '\0') |
| 3926 | return mask; | ||
| 3950 | if (*string == '=') | 3927 | if (*string == '=') |
| 3951 | string++; /* ignore possible '=' at beg of geometry spec */ | 3928 | string++; /* ignore possible '=' at beg of geometry spec */ |
| 3952 | 3929 | ||
| 3953 | strind = (char *)string; | 3930 | strind = string; |
| 3954 | if (*strind != '+' && *strind != '-' && *strind != 'x') | 3931 | if (*strind != '+' && *strind != '-' && *strind != 'x') |
| 3955 | { | 3932 | { |
| 3956 | tempWidth = read_integer (strind, &nextCharacter); | 3933 | tempWidth = strtoul (strind, &nextCharacter, 10); |
| 3957 | if (strind == nextCharacter) | 3934 | if (strind == nextCharacter) |
| 3958 | return (0); | 3935 | return 0; |
| 3959 | strind = nextCharacter; | 3936 | strind = nextCharacter; |
| 3960 | mask |= WidthValue; | 3937 | mask |= WidthValue; |
| 3961 | } | 3938 | } |
| @@ -3963,53 +3940,30 @@ XParseGeometry (char *string, | |||
| 3963 | if (*strind == 'x' || *strind == 'X') | 3940 | if (*strind == 'x' || *strind == 'X') |
| 3964 | { | 3941 | { |
| 3965 | strind++; | 3942 | strind++; |
| 3966 | tempHeight = read_integer (strind, &nextCharacter); | 3943 | tempHeight = strtoul (strind, &nextCharacter, 10); |
| 3967 | if (strind == nextCharacter) | 3944 | if (strind == nextCharacter) |
| 3968 | return (0); | 3945 | return 0; |
| 3969 | strind = nextCharacter; | 3946 | strind = nextCharacter; |
| 3970 | mask |= HeightValue; | 3947 | mask |= HeightValue; |
| 3971 | } | 3948 | } |
| 3972 | 3949 | ||
| 3973 | if ((*strind == '+') || (*strind == '-')) | 3950 | if (*strind == '+' || *strind == '-') |
| 3974 | { | 3951 | { |
| 3975 | if (*strind == '-') | 3952 | if (*strind == '-') |
| 3976 | { | 3953 | mask |= XNegative; |
| 3977 | strind++; | 3954 | tempX = strtol (strind, &nextCharacter, 10); |
| 3978 | tempX = -read_integer (strind, &nextCharacter); | 3955 | if (strind == nextCharacter) |
| 3979 | if (strind == nextCharacter) | 3956 | return 0; |
| 3980 | return (0); | 3957 | strind = nextCharacter; |
| 3981 | strind = nextCharacter; | ||
| 3982 | mask |= XNegative; | ||
| 3983 | |||
| 3984 | } | ||
| 3985 | else | ||
| 3986 | { | ||
| 3987 | strind++; | ||
| 3988 | tempX = read_integer (strind, &nextCharacter); | ||
| 3989 | if (strind == nextCharacter) | ||
| 3990 | return (0); | ||
| 3991 | strind = nextCharacter; | ||
| 3992 | } | ||
| 3993 | mask |= XValue; | 3958 | mask |= XValue; |
| 3994 | if ((*strind == '+') || (*strind == '-')) | 3959 | if (*strind == '+' || *strind == '-') |
| 3995 | { | 3960 | { |
| 3996 | if (*strind == '-') | 3961 | if (*strind == '-') |
| 3997 | { | 3962 | mask |= YNegative; |
| 3998 | strind++; | 3963 | tempY = strtol (strind, &nextCharacter, 10); |
| 3999 | tempY = -read_integer (strind, &nextCharacter); | 3964 | if (strind == nextCharacter) |
| 4000 | if (strind == nextCharacter) | 3965 | return 0; |
| 4001 | return (0); | 3966 | strind = nextCharacter; |
| 4002 | strind = nextCharacter; | ||
| 4003 | mask |= YNegative; | ||
| 4004 | } | ||
| 4005 | else | ||
| 4006 | { | ||
| 4007 | strind++; | ||
| 4008 | tempY = read_integer (strind, &nextCharacter); | ||
| 4009 | if (strind == nextCharacter) | ||
| 4010 | return (0); | ||
| 4011 | strind = nextCharacter; | ||
| 4012 | } | ||
| 4013 | mask |= YValue; | 3967 | mask |= YValue; |
| 4014 | } | 3968 | } |
| 4015 | } | 3969 | } |
| @@ -4017,17 +3971,18 @@ XParseGeometry (char *string, | |||
| 4017 | /* If strind isn't at the end of the string then it's an invalid | 3971 | /* If strind isn't at the end of the string then it's an invalid |
| 4018 | geometry specification. */ | 3972 | geometry specification. */ |
| 4019 | 3973 | ||
| 4020 | if (*strind != '\0') return (0); | 3974 | if (*strind != '\0') |
| 3975 | return 0; | ||
| 4021 | 3976 | ||
| 4022 | if (mask & XValue) | 3977 | if (mask & XValue) |
| 4023 | *x = tempX; | 3978 | *x = clip_to_bounds (INT_MIN, tempX, INT_MAX); |
| 4024 | if (mask & YValue) | 3979 | if (mask & YValue) |
| 4025 | *y = tempY; | 3980 | *y = clip_to_bounds (INT_MIN, tempY, INT_MAX); |
| 4026 | if (mask & WidthValue) | 3981 | if (mask & WidthValue) |
| 4027 | *width = tempWidth; | 3982 | *width = min (tempWidth, UINT_MAX); |
| 4028 | if (mask & HeightValue) | 3983 | if (mask & HeightValue) |
| 4029 | *height = tempHeight; | 3984 | *height = min (tempHeight, UINT_MAX); |
| 4030 | return (mask); | 3985 | return mask; |
| 4031 | } | 3986 | } |
| 4032 | 3987 | ||
| 4033 | #endif /* !defined (HAVE_X_WINDOWS) && defined (NoValue) */ | 3988 | #endif /* !defined (HAVE_X_WINDOWS) && defined (NoValue) */ |