size_t parse_util_get_offset(const wcstring &str, int line, long line_offset) { const wchar_t *buff = str.c_str(); size_t off = parse_util_get_offset_from_line(buff, line); size_t off2 = parse_util_get_offset_from_line(buff, line+1); long line_offset2 = line_offset; if (off == (size_t)(-1)) { return -1; } if (off2 == (size_t)(-1)) { off2 = wcslen(buff)+1; } if (line_offset2 < 0) { line_offset2 = 0; } if (line_offset2 >= off2-off-1) { line_offset2 = off2-off-1; } return off + line_offset2; }
int parse_util_get_offset( wchar_t *buff, int line, int line_offset ) { int off = parse_util_get_offset_from_line( buff, line ); int off2 = parse_util_get_offset_from_line( buff, line+1 ); int line_offset2 = line_offset; if( off < 0 ) { return -1; } if( off2 < 0 ) { off2 = wcslen( buff )+1; } if( line_offset2 < 0 ) { line_offset2 = 0; } if( line_offset2 >= off2-off-1 ) { line_offset2 = off2-off-1; } return off + line_offset2; }