Partially sync files.el from XEmacs 21.5 for wildcard support.
[sxemacs] / src / doprnt.c
index 6bf4b74..efedd95 100644 (file)
@@ -29,6 +29,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>. */
 
 #include "buffer.h"
 #include "lstream.h"
+#include "ent/ent.h"
 
 static const char *const valid_flags = "-+ #0";
 static const char *const valid_converters = "dic" "oxX" "feEgG" "sS" "b"
@@ -489,7 +490,7 @@ __ulong_to_bit_string(char *p, long unsigned int number)
 {
        int i, seen_high_order = 0;
        char *origp = p;
-  
+
        for (i = ((SIZEOF_LONG * 8) - 1); i >= 0; --i) {
                if (number & 1UL << i) {
                        seen_high_order = 1;
@@ -1332,7 +1333,7 @@ emacs_doprnt_1(Lisp_Object stream, const Bufbyte * format_nonreloc,
        } else {
                args = get_doprnt_args(specs, vargs);
        }
-       
+
        for (i = 0; specs && i < Dynarr_length(specs); i++) {
                printf_spec_t spec = Dynarr_atp(specs, i);
                char ch;
@@ -1358,26 +1359,30 @@ emacs_doprnt_1(Lisp_Object stream, const Bufbyte * format_nonreloc,
                   was specified as an argument.  Extract the data and forward
                   it to the next spec, to which it will apply.  */
                if (ch == '*') {
-                       printf_spec_t nextspec = Dynarr_atp(specs, i + 1);
-                       Lisp_Object obj = largs[spec->argnum - 1];
+                       if(!largs) {
+                               error("Invalid largs and '*' converter in emacs_doprnt_1");
+                       } else {
+                               printf_spec_t nextspec = Dynarr_atp(specs, i + 1);
+                               Lisp_Object obj = largs[spec->argnum - 1];
 
-                       if (INTP(obj)) {
-                               if (spec->forwarding_precision) {
-                                       nextspec->precision = XINT(obj);
-                                       nextspec->minwidth = spec->minwidth;
-                               } else {
-                                       nextspec->minwidth = XINT(obj);
-                                       if (XINT(obj) < 0) {
-                                               spec->minus_flag = 1;
-                                               nextspec->minwidth =
-                                                   -nextspec->minwidth;
+                               if (INTP(obj)) {
+                                       if (spec->forwarding_precision) {
+                                               nextspec->precision = XINT(obj);
+                                               nextspec->minwidth = spec->minwidth;
+                                       } else {
+                                               nextspec->minwidth = XINT(obj);
+                                               if (XINT(obj) < 0) {
+                                                       spec->minus_flag = 1;
+                                                       nextspec->minwidth =
+                                                               -nextspec->minwidth;
+                                               }
                                        }
+                                       nextspec->minus_flag = spec->minus_flag;
+                                       nextspec->plus_flag = spec->plus_flag;
+                                       nextspec->space_flag = spec->space_flag;
+                                       nextspec->number_flag = spec->number_flag;
+                                       nextspec->zero_flag = spec->zero_flag;
                                }
-                               nextspec->minus_flag = spec->minus_flag;
-                               nextspec->plus_flag = spec->plus_flag;
-                               nextspec->space_flag = spec->space_flag;
-                               nextspec->number_flag = spec->number_flag;
-                               nextspec->zero_flag = spec->zero_flag;
                        }
                        continue;
                }