PennMUSH Community

Ticket #7575: just-fill.patch.txt

File just-fill.patch.txt, 3.0 kB (added by Talvo, 7 months ago)
Line 
1 *** src/funstr.c.orig   Fri Oct  5 23:36:32 2007
2 --- src/funstr.c    Thu May  1 04:57:45 2008
3 ***************
4 *** 958,964 ****
5     /* pads a string with trailing blanks (or other fill character) */
6  
7     size_t spaces, len;
8 !   char sep;
9  
10     if (!is_uinteger(args[1])) {
11       safe_str(T(e_uint), buff, bp);
12 --- 958,966 ----
13     /* pads a string with trailing blanks (or other fill character) */
14  
15     size_t spaces, len;
16 !   ansi_string *as;
17 !   int fillq, fillr, i;
18 !   char fillstr[BUFFER_LEN], *fp;
19  
20     if (!is_uinteger(args[1])) {
21       safe_str(T(e_uint), buff, bp);
22 ***************
23 *** 975,985 ****
24     }
25     spaces -= len;
26  
27 !   if (!delim_check(buff, bp, nargs, args, 3, &sep))
28       return;
29 !
30     safe_strl(args[0], arglens[0], buff, bp);
31 !   safe_fill(sep, spaces, buff, bp);
32   }
33  
34   /* ARGSUSED */
35 --- 977,1005 ----
36     }
37     spaces -= len;
38  
39 !   if (!args[2] || !*args[2]) {
40 !     /* Fill with spaces */
41 !     safe_strl(args[0], arglens[0], buff, bp);
42 !     safe_fill(' ', spaces, buff, bp);
43       return;
44 !   }
45 !   len = ansi_strlen(args[2]);
46 !   if (!len) {
47 !     safe_str(T("#-1 FILL ARGUMENT MAY NOT BE ZERO-LENGTH"), buff, bp);
48 !     return;
49 !   }
50     safe_strl(args[0], arglens[0], buff, bp);
51 !   as = parse_ansi_string(args[2]);
52 !   fillq = spaces / len;
53 !   fillr = spaces % len;
54 !   fp = fillstr;
55 !   for (i = 0; i < fillq; i++)
56 !     safe_ansi_string(as, 0, as->len, fillstr, &fp);
57 !   safe_ansi_string(as, 0, fillr, fillstr, &fp);
58 !   *fp = '\0';
59 !   free_ansi_string(as);
60 !   safe_str(fillstr, buff, bp);
61 !
62   }
63  
64   /* ARGSUSED */
65 ***************
66 *** 988,994 ****
67     /* pads a string with leading blanks (or other fill character) */
68  
69     size_t spaces, len;
70 !   char sep;
71  
72     if (!is_uinteger(args[1])) {
73       safe_str(T(e_uint), buff, bp);
74 --- 1008,1017 ----
75     /* pads a string with leading blanks (or other fill character) */
76  
77     size_t spaces, len;
78 !   ansi_string *as;
79 !   int fillq, fillr, i;
80 !   char fillstr[BUFFER_LEN], *fp;
81 !
82  
83     if (!is_uinteger(args[1])) {
84       safe_str(T(e_uint), buff, bp);
85 ***************
86 *** 1005,1015 ****
87     }
88     spaces -= len;
89  
90 !   if (!delim_check(buff, bp, nargs, args, 3, &sep))
91       return;
92 !
93 !   safe_fill(sep, spaces, buff, bp);
94     safe_strl(args[0], arglens[0], buff, bp);
95   }
96  
97   /* ARGSUSED */
98 --- 1028,1056 ----
99     }
100     spaces -= len;
101  
102 !   if (!args[2] || !*args[2]) {
103 !     /* Fill with spaces */
104 !     safe_fill(' ', spaces, buff, bp);
105 !     safe_strl(args[0], arglens[0], buff, bp);
106       return;
107 !   }
108 !   len = ansi_strlen(args[2]);
109 !   if (!len) {
110 !     safe_str(T("#-1 FILL ARGUMENT MAY NOT BE ZERO-LENGTH"), buff, bp);
111 !     return;
112 !   }
113 !   as = parse_ansi_string(args[2]);
114 !   fillq = spaces / len;
115 !   fillr = spaces % len;
116 !   fp = fillstr;
117 !   for (i = 0; i < fillq; i++)
118 !     safe_ansi_string(as, 0, as->len, fillstr, &fp);
119 !   safe_ansi_string(as, 0, fillr, fillstr, &fp);
120 !   *fp = '\0';
121 !   free_ansi_string(as);
122 !   safe_str(fillstr, buff, bp);
123     safe_strl(args[0], arglens[0], buff, bp);
124 +
125   }
126  
127   /* ARGSUSED */