~ubuntu-branches/ubuntu/wily/julia/wily

« back to all changes in this revision

Viewing changes to src/support/utf8.c

  • Committer: Package Import Robot
  • Author(s): Sébastien Villemot
  • Date: 2013-02-06 17:54:29 UTC
  • mfrom: (1.1.3)
  • Revision ID: package-import@ubuntu.com-20130206175429-13br5kqpkfjqdmre
Tags: 0.0.0+20130206.git32ff5759-1
* New upstream snapshot.
* debian/copyright: reflect upstream changes
* debian/rules: update get-orig-source to reflect upstream changes
   + Don't ship nginx
   + Adapt for new configure-random target in deps/Makefile
* Enable build of Tk wrapper.
   + debian/control: add build dependency on tk-dev
   + debian/rules: add tk rule to build-arch
* debian/julia.install: install VERSION and COMMIT files
* no-webrepl.patch: new patch
* Refresh other patches
* Add source override for config.status file under deps/random/

Show diffs side-by-side

added added

removed removed

Lines of Context:
75
75
{
76
76
    size_t i, c=0;
77
77
 
78
 
    for(i=0; i < n; i++)
79
 
        c += u8_charlen(wcstr[i]);
 
78
    for(i=0; i < n; i++) {
 
79
        size_t cl = u8_charlen(wcstr[i]);
 
80
        if (cl == 0) cl = 3;  // invalid: encoded as replacement char
 
81
        c += cl;
 
82
    }
80
83
    return c;
81
84
}
82
85
 
165
168
            *dest++ = ((ch>>6) & 0x3F) | 0x80;
166
169
            *dest++ = (ch & 0x3F) | 0x80;
167
170
        }
 
171
        else {
 
172
            if (dest >= dest_end-2)
 
173
                break;
 
174
            // invalid: use replacement char \ufffd
 
175
            *dest++ = 0xef;
 
176
            *dest++ = 0xbf;
 
177
            *dest++ = 0xbd;
 
178
        }
168
179
        i++;
169
180
    }
170
181
    return (dest-dest0);
194
205
        dest[3] = (ch & 0x3F) | 0x80;
195
206
        return 4;
196
207
    }
197
 
    return 0;
 
208
    dest[0] = 0xef;
 
209
    dest[1] = 0xbf;
 
210
    dest[2] = 0xbd;
 
211
    return 3;
198
212
}
199
213
 
200
214
/* charnum => byte offset */
243
257
    return count;
244
258
}
245
259
 
246
 
extern int wcwidth(wchar_t c);
 
260
#if defined(__WIN32__) || defined(__linux__)
 
261
extern int wcwidth(uint32_t ch);
 
262
#endif
247
263
 
248
264
size_t u8_strwidth(const char *s)
249
265
{
272
288
            }
273
289
            ch -= offsetsFromUTF8[nb];
274
290
            w = wcwidth(ch);  // might return -1
 
291
            w=0;
275
292
            if (w > 0) tot += w;
276
293
        }
277
294
    }