File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed
Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -29,6 +29,7 @@ THIS SOFTWARE.
2929#include <errno.h>
3030#include <stdlib.h>
3131#include <stdarg.h>
32+ #include <utf.h>
3233#include "awk.h"
3334#include "ytab.h"
3435
@@ -306,15 +307,18 @@ void fldbld(void) /* create fields from current record */
306307 }
307308 * fr = 0 ;
308309 } else if ((sep = * inputFS ) == 0 ) { /* new: FS="" => 1 char/field */
309- for (i = 0 ; * r != 0 ; r ++ ) {
310- char buf [2 ];
310+ int nb ;
311+ for (i = 0 ; * r != 0 ; r += nb ) {
312+ Rune rr ;
313+ char buf [UTFmax + 1 ];
311314 i ++ ;
312315 if (i > nfields )
313316 growfldtab (i );
314317 if (freeable (fldtab [i ]))
315318 xfree (fldtab [i ]-> sval );
316- buf [0 ] = * r ;
317- buf [1 ] = 0 ;
319+ nb = chartorune (& rr , r );
320+ memmove (buf , r , nb );
321+ buf [nb ] = '\0' ;
318322 fldtab [i ]-> sval = tostring (buf );
319323 fldtab [i ]-> tval = FLD | STR ;
320324 }
You can’t perform that action at this time.
0 commit comments