Changeset 7dcb7981 in mainline for uspace/app/bdsh/tok.c
- Timestamp:
- 2011-08-19T11:35:08Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 89660f2
- Parents:
- 42a619b
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/bdsh/tok.c
r42a619b r7dcb7981 50 50 * @param max_tokens number of elements of the out_tokens array 51 51 */ 52 int tok_init(tokenizer_t *tok, char *input, char **out_tokens,52 int tok_init(tokenizer_t *tok, char *input, token_t *out_tokens, 53 53 size_t max_tokens) 54 54 { 55 55 tok->in = input; 56 56 tok->in_offset = 0; 57 tok->last_in_offset = 0; 58 tok->in_char_offset = 0; 59 tok->last_in_char_offset = 0; 57 60 58 61 tok->outtok = out_tokens; … … 201 204 wchar_t tok_get_char(tokenizer_t *tok) 202 205 { 206 tok->in_char_offset++; 203 207 return str_decode(tok->in, &tok->in_offset, STR_NO_LIMIT); 204 208 } … … 207 211 wchar_t tok_look_char(tokenizer_t *tok) 208 212 { 209 size_t old_offset = tok->in_offset; 213 off_t old_offset = tok->in_offset; 214 off_t old_char_offset = tok->in_char_offset; 210 215 wchar_t ret = tok_get_char(tok); 211 216 tok->in_offset = old_offset; 217 tok->in_char_offset = old_char_offset; 212 218 return ret; 213 219 } … … 231 237 232 238 tok->outbuf[tok->outbuf_offset++] = 0; 233 tok->outtok[tok->outtok_offset++] = tok->outbuf + tok->outbuf_last_start; 239 token_t *tokinfo = &tok->outtok[tok->outtok_offset++] 240 tokinfo.text = tok->outbuf + tok->outbuf_last_start; 241 tokinfo.byte_start = tok->last_in_offset; 242 tokinfo.byte_length = tok->in_offset - tok->last_in_offset - 1; 243 tokinfo.char_start = tok->last_in_char_offset; 244 tokinfo.char_length = tok->in_char_offset - tok->last_in_char_offset 245 - 1; 246 tok->outtok[tok->outtok_offset] 234 247 tok->outbuf_last_start = tok->outbuf_offset; 248 249 /* We have consumed the first char of the next token already */ 250 tok->last_in_offset = tok->in_offset-1; 251 tok->last_in_char_offset = tok->in_char_offset-1; 235 252 236 253 return EOK;
Note:
See TracChangeset
for help on using the changeset viewer.