static struct text_pos run_window_scroll_functions (Lisp_Object,
struct text_pos);
static void reconsider_clip_changes (struct window *, struct buffer *);
-static int text_outside_line_unchanged_p (struct window *, int, int);
+static int text_outside_line_unchanged_p (struct window *,
+ EMACS_INT, EMACS_INT);
static void store_mode_line_noprop_char (char);
static int store_mode_line_noprop (const unsigned char *, int, int);
static void x_consider_frame_title (Lisp_Object);
static int cursor_row_fully_visible_p (struct window *, int, int);
static int try_scrolling (Lisp_Object, int, EMACS_INT, EMACS_INT, int, int);
static int try_cursor_movement (Lisp_Object, struct text_pos, int *);
-static int trailing_whitespace_p (int);
-static int message_log_check_duplicate (int, int, int, int);
+static int trailing_whitespace_p (EMACS_INT);
+static int message_log_check_duplicate (EMACS_INT, EMACS_INT,
+ EMACS_INT, EMACS_INT);
static void push_it (struct it *);
static void pop_it (struct it *);
static void sync_frame_with_window_matrix_rows (struct window *);
static const char *decode_mode_spec (struct window *, int, int, int,
Lisp_Object *);
static void display_menu_bar (struct window *);
-static int display_count_lines (int, int, int, int, int *);
+static int display_count_lines (EMACS_INT, EMACS_INT, EMACS_INT, int,
+ EMACS_INT *);
static int display_string (const unsigned char *, Lisp_Object, Lisp_Object,
EMACS_INT, EMACS_INT, struct it *, int, int, int, int);
static void compute_line_metrics (struct it *);
static void run_redisplay_end_trigger_hook (struct it *);
-static int get_overlay_strings (struct it *, int);
-static int get_overlay_strings_1 (struct it *, int, int);
+static int get_overlay_strings (struct it *, EMACS_INT);
+static int get_overlay_strings_1 (struct it *, EMACS_INT, int);
static void next_overlay_string (struct it *);
static void reseat (struct it *, struct text_pos, int);
static void reseat_1 (struct it *, struct text_pos, int);
static int next_element_from_composition (struct it *);
static int next_element_from_image (struct it *);
static int next_element_from_stretch (struct it *);
-static void load_overlay_strings (struct it *, int);
+static void load_overlay_strings (struct it *, EMACS_INT);
static int init_from_display_pos (struct it *, struct window *,
struct display_pos *);
static void reseat_to_string (struct it *, const unsigned char *,
- Lisp_Object, int, int, int, int);
+ Lisp_Object, EMACS_INT, EMACS_INT, int, int);
static enum move_it_result
move_it_in_display_line_to (struct it *, EMACS_INT, int,
enum move_operation_enum);
static struct text_pos string_pos_nchars_ahead (struct text_pos,
Lisp_Object, EMACS_INT);
static struct text_pos string_pos (EMACS_INT, Lisp_Object);
-static struct text_pos c_string_pos (int, const unsigned char *, int);
-static int number_of_chars (const unsigned char *, int);
+static struct text_pos c_string_pos (EMACS_INT, const unsigned char *, int);
+static EMACS_INT number_of_chars (const unsigned char *, int);
static void compute_stop_pos (struct it *);
static void compute_string_pos (struct text_pos *, struct text_pos,
Lisp_Object);
Set *ROWH and *VPOS to row's visible height and VPOS (row number). */
int
-pos_visible_p (struct window *w, int charpos, int *x, int *y,
+pos_visible_p (struct window *w, EMACS_INT charpos, int *x, int *y,
int *rtop, int *rbot, int *rowh, int *vpos)
{
struct it it;
means recognize multibyte characters. */
static struct text_pos
-c_string_pos (int charpos, const unsigned char *s, int multibyte_p)
+c_string_pos (EMACS_INT charpos, const unsigned char *s, int multibyte_p)
{
struct text_pos pos;
if (multibyte_p)
{
- int rest = strlen (s), len;
+ EMACS_INT rest = strlen (s);
+ int len;
SET_TEXT_POS (pos, 0, 0);
while (charpos--)
/* Value is the number of characters in C string S. MULTIBYTE_P
non-zero means recognize multibyte characters. */
-static int
+static EMACS_INT
number_of_chars (const unsigned char *s, int multibyte_p)
{
- int nchars;
+ EMACS_INT nchars;
if (multibyte_p)
{
- int rest = strlen (s), len;
+ EMACS_INT rest = strlen (s);
+ int len;
unsigned char *p = (unsigned char *) s;
for (nchars = 0; rest > 0; ++nchars)
if (STRING_MULTIBYTE (it->string))
{
const unsigned char *p = SDATA (it->string) + BYTEPOS (pos);
- EMACS_INT rest = SBYTES (it->string) - BYTEPOS (pos);
int c, len;
struct face *face = FACE_FROM_ID (it->f, face_id);
compare_overlay_entries. */
static void
-load_overlay_strings (struct it *it, int charpos)
+load_overlay_strings (struct it *it, EMACS_INT charpos)
{
Lisp_Object overlay, window, str, invisible;
struct Lisp_Overlay *ov;
- int start, end;
+ EMACS_INT start, end;
int size = 20;
int n = 0, i, j, invis_p;
struct overlay_entry *entries
least one overlay string was found. */
static int
-get_overlay_strings_1 (struct it *it, int charpos, int compute_stop_p)
+get_overlay_strings_1 (struct it *it, EMACS_INT charpos, int compute_stop_p)
{
/* Get the first OVERLAY_STRING_CHUNK_SIZE overlay strings to
process. This fills IT->overlay_strings with strings, and sets
}
static int
-get_overlay_strings (struct it *it, int charpos)
+get_overlay_strings (struct it *it, EMACS_INT charpos)
{
it->string = Qnil;
it->method = GET_FROM_BUFFER;
short-cut. */
if (!newline_found_p)
{
- int start = IT_CHARPOS (*it);
- int limit = find_next_newline_no_quit (start, 1);
+ EMACS_INT start = IT_CHARPOS (*it);
+ EMACS_INT limit = find_next_newline_no_quit (start, 1);
Lisp_Object pos;
xassert (!STRINGP (it->string));
{
struct it it2;
- int pos;
+ EMACS_INT pos;
EMACS_INT beg, end;
Lisp_Object val, overlay;
static void
reseat (struct it *it, struct text_pos pos, int force_p)
{
- int original_pos = IT_CHARPOS (*it);
+ EMACS_INT original_pos = IT_CHARPOS (*it);
reseat_1 (it, pos, 0);
static void
reseat_to_string (struct it *it, const unsigned char *s, Lisp_Object string,
- int charpos, int precision, int field_width, int multibyte)
+ EMACS_INT charpos, EMACS_INT precision, int field_width,
+ int multibyte)
{
/* No region in strings. */
it->region_beg_charpos = it->region_end_charpos = -1;
}
else
{
- int pos = (it->s ? -1
- : STRINGP (it->string) ? IT_STRING_CHARPOS (*it)
- : IT_CHARPOS (*it));
+ EMACS_INT pos = (it->s ? -1
+ : STRINGP (it->string) ? IT_STRING_CHARPOS (*it)
+ : IT_CHARPOS (*it));
it->face_id = FACE_FOR_CHAR (it->f, face, it->char_to_display, pos,
it->string);
}
else if (STRING_MULTIBYTE (it->string))
{
- int remaining = SBYTES (it->string) - IT_STRING_BYTEPOS (*it);
const unsigned char *s = (SDATA (it->string)
+ IT_STRING_BYTEPOS (*it));
it->c = string_char_and_length (s, &it->len);
}
else if (STRING_MULTIBYTE (it->string))
{
- int maxlen = SBYTES (it->string) - IT_STRING_BYTEPOS (*it);
const unsigned char *s = (SDATA (it->string)
+ IT_STRING_BYTEPOS (*it));
it->c = string_char_and_length (s, &it->len);
BYTEPOS (it->position) = CHARPOS (it->position) = -1;
}
else if (it->multibyte_p)
- {
- /* Implementation note: The calls to strlen apparently aren't a
- performance problem because there is no noticeable performance
- difference between Emacs running in unibyte or multibyte mode. */
- int maxlen = strlen (it->s) - IT_BYTEPOS (*it);
- it->c = string_char_and_length (it->s + IT_BYTEPOS (*it), &it->len);
- }
+ it->c = string_char_and_length (it->s + IT_BYTEPOS (*it), &it->len);
else
it->c = it->s[IT_BYTEPOS (*it)], it->len = 1;
}
else
{
- int orig_bytepos = IT_BYTEPOS (*it);
+ EMACS_INT orig_bytepos = IT_BYTEPOS (*it);
/* We need to prime the bidi iterator starting at the line's
beginning, before we will be able to produce the next
{
int nlines, h;
struct it it2, it3;
- int start_pos;
+ EMACS_INT start_pos;
move_further_back:
xassert (dy >= 0);
void
move_it_by_lines (struct it *it, int dvpos, int need_y_p)
{
- struct position pos;
/* The commented-out optimization uses vmotion on terminals. This
gives bad results, because elements like it->what, on which
callers such as pos_visible_p rely, aren't updated. */
- /* if (!FRAME_WINDOW_P (it->f))
+ /* struct position pos;
+ if (!FRAME_WINDOW_P (it->f))
{
struct text_pos textpos;
else
{
struct it it2;
- int start_charpos, i;
+ EMACS_INT start_charpos, i;
/* Start at the beginning of the screen line containing IT's
position. This may actually move vertically backwards,
Lisp_Object args[3];
Lisp_Object msg, fmt;
char *buffer;
- int len;
+ EMACS_INT len;
struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
USE_SAFE_ALLOCA;
struct buffer *oldbuf;
Lisp_Object oldpoint, oldbegv, oldzv;
int old_windows_or_buffers_changed = windows_or_buffers_changed;
- int point_at_end = 0;
- int zv_at_end = 0;
+ EMACS_INT point_at_end = 0;
+ EMACS_INT zv_at_end = 0;
Lisp_Object old_deactivate_mark, tem;
struct gcpro gcpro1;
if (multibyte
&& NILP (current_buffer->enable_multibyte_characters))
{
- int i, c, char_bytes;
+ EMACS_INT i;
+ int c, char_bytes;
unsigned char work[1];
/* Convert a multibyte string to single-byte
else if (! multibyte
&& ! NILP (current_buffer->enable_multibyte_characters))
{
- int i, c, char_bytes;
+ EMACS_INT i;
+ int c, char_bytes;
unsigned char *msg = (unsigned char *) m;
unsigned char str[MAX_MULTIBYTE_LENGTH];
/* Convert a single-byte string to multibyte
if (nlflag)
{
- int this_bol, this_bol_byte, prev_bol, prev_bol_byte, dup;
+ EMACS_INT this_bol, this_bol_byte, prev_bol, prev_bol_byte;
+ int dup;
insert_1 ("\n", 1, 1, 0, 0);
scan_newline (Z, Z_BYTE, BEG, BEG_BYTE, -2, 0);
value N > 1 if we should also append " [N times]". */
static int
-message_log_check_duplicate (int prev_bol, int prev_bol_byte,
- int this_bol, int this_bol_byte)
+message_log_check_duplicate (EMACS_INT prev_bol, EMACS_INT prev_bol_byte,
+ EMACS_INT this_bol, EMACS_INT this_bol_byte)
{
- int i;
- int len = Z_BYTE - 1 - this_bol_byte;
+ EMACS_INT i;
+ EMACS_INT len = Z_BYTE - 1 - this_bol_byte;
int seen_dots = 0;
unsigned char *p1 = BUF_BYTE_ADDRESS (current_buffer, prev_bol_byte);
unsigned char *p2 = BUF_BYTE_ADDRESS (current_buffer, this_bol_byte);
This may GC, so the buffer M must NOT point to a Lisp string. */
void
-message2 (const char *m, int nbytes, int multibyte)
+message2 (const char *m, EMACS_INT nbytes, int multibyte)
{
/* First flush out any partial line written with print. */
message_log_maybe_newline ();
/* The non-logging counterpart of message2. */
void
-message2_nolog (const char *m, int nbytes, int multibyte)
+message2_nolog (const char *m, EMACS_INT nbytes, int multibyte)
{
struct frame *sf = SELECTED_FRAME ();
message_enable_multibyte = multibyte;
This function cancels echoing. */
void
-message3 (Lisp_Object m, int nbytes, int multibyte)
+message3 (Lisp_Object m, EMACS_INT nbytes, int multibyte)
{
struct gcpro gcpro1;
and make this cancel echoing. */
void
-message3_nolog (Lisp_Object m, int nbytes, int multibyte)
+message3_nolog (Lisp_Object m, EMACS_INT nbytes, int multibyte)
{
struct frame *sf = SELECTED_FRAME ();
message_enable_multibyte = multibyte;
{
if (m)
{
- int len;
+ EMACS_INT len;
len = doprnt (FRAME_MESSAGE_BUF (f),
FRAME_MESSAGE_BUF_SIZE (f), m, (char *)0, ap);
*/
void
-set_message (const char *s, Lisp_Object string, int nbytes, int multibyte_p)
+set_message (const char *s, Lisp_Object string,
+ EMACS_INT nbytes, int multibyte_p)
{
message_enable_multibyte
= ((s && multibyte_p)
if (STRINGP (string))
{
- int nchars;
+ EMACS_INT nchars;
if (nbytes == 0)
nbytes = SBYTES (string);
if (multibyte_p && NILP (current_buffer->enable_multibyte_characters))
{
/* Convert from multi-byte to single-byte. */
- int i, c, n;
+ EMACS_INT i;
+ int c, n;
unsigned char work[1];
/* Convert a multibyte string to single-byte. */
&& !NILP (current_buffer->enable_multibyte_characters))
{
/* Convert from single-byte to multi-byte. */
- int i, c, n;
+ EMACS_INT i;
+ int c, n;
const unsigned char *msg = (const unsigned char *) s;
unsigned char str[MAX_MULTIBYTE_LENGTH];
struct it it;
int hscroll;
struct buffer *saved_current_buffer;
- int pt;
+ EMACS_INT pt;
int wanted_x;
/* Find point in a display of infinite width. */
redisplay_internal for display optimization. */
static INLINE int
-text_outside_line_unchanged_p (struct window *w, int start, int end)
+text_outside_line_unchanged_p (struct window *w,
+ EMACS_INT start, EMACS_INT end)
{
int unchanged_p = 1;
struct glyph *end = glyph + row->used[TEXT_AREA];
struct glyph *cursor = NULL;
/* The last known character position in row. */
- int last_pos = MATRIX_ROW_START_CHARPOS (row) + delta;
+ EMACS_INT last_pos = MATRIX_ROW_START_CHARPOS (row) + delta;
int x = row->x;
EMACS_INT pt_old = PT - delta;
EMACS_INT pos_before = MATRIX_ROW_START_CHARPOS (row) + delta;
else if (STRINGP (glyph->object))
{
Lisp_Object chprop;
- int glyph_pos = glyph->charpos;
+ EMACS_INT glyph_pos = glyph->charpos;
chprop = Fget_char_property (make_number (glyph_pos), Qcursor,
glyph->object);
else if (STRINGP (glyph->object))
{
Lisp_Object chprop;
- int glyph_pos = glyph->charpos;
+ EMACS_INT glyph_pos = glyph->charpos;
chprop = Fget_char_property (make_number (glyph_pos), Qcursor,
glyph->object);
be a character in the string with the
`cursor' property, which means display
cursor on that character's glyph. */
- int strpos = glyph->charpos;
+ EMACS_INT strpos = glyph->charpos;
cursor = glyph;
for (glyph += incr;
glyph += incr)
{
Lisp_Object cprop;
- int gpos = glyph->charpos;
+ EMACS_INT gpos = glyph->charpos;
cprop = Fget_char_property (make_number (gpos),
Qcursor,
void
set_vertical_scroll_bar (struct window *w)
{
- int start, end, whole;
+ EMACS_INT start, end, whole;
/* Calculate the start and end positions for the current window.
At some point, it would be nice to choose between scrollbars
int rc;
int centering_position = -1;
int last_line_misfit = 0;
- int beg_unchanged, end_unchanged;
+ EMACS_INT beg_unchanged, end_unchanged;
SET_TEXT_POS (lpoint, PT, PT_BYTE);
opoint = lpoint;
window, set up appropriate value. */
if (!EQ (window, selected_window))
{
- int new_pt = XMARKER (w->pointm)->charpos;
- int new_pt_byte = marker_byte_position (w->pointm);
+ EMACS_INT new_pt = XMARKER (w->pointm)->charpos;
+ EMACS_INT new_pt_byte = marker_byte_position (w->pointm);
if (new_pt < BEGV)
{
new_pt = BEGV;
static struct glyph_row *
find_last_unchanged_at_beg_row (struct window *w)
{
- int first_changed_pos = BEG + BEG_UNCHANGED;
+ EMACS_INT first_changed_pos = BEG + BEG_UNCHANGED;
struct glyph_row *row;
struct glyph_row *row_found = NULL;
int yb = window_text_bottom_y (w);
corresponds to window_end_pos. This allows us to translate
buffer positions in the current matrix to current buffer
positions for characters not in changed text. */
- int Z_old = MATRIX_ROW_END_CHARPOS (row) + XFASTINT (w->window_end_pos);
- int Z_BYTE_old = MATRIX_ROW_END_BYTEPOS (row) + w->window_end_bytepos;
- int last_unchanged_pos, last_unchanged_pos_old;
+ EMACS_INT Z_old =
+ MATRIX_ROW_END_CHARPOS (row) + XFASTINT (w->window_end_pos);
+ EMACS_INT Z_BYTE_old =
+ MATRIX_ROW_END_BYTEPOS (row) + w->window_end_bytepos;
+ EMACS_INT last_unchanged_pos, last_unchanged_pos_old;
struct glyph_row *first_text_row
= MATRIX_FIRST_TEXT_ROW (w->current_matrix);
containing CHARPOS or null. */
struct glyph_row *
-row_containing_pos (struct window *w, int charpos, struct glyph_row *start,
- struct glyph_row *end, int dy)
+row_containing_pos (struct window *w, EMACS_INT charpos,
+ struct glyph_row *start, struct glyph_row *end, int dy)
{
struct glyph_row *row = start;
struct glyph_row *best_row = NULL;
trailing whitespace. */
static int
-trailing_whitespace_p (int charpos)
+trailing_whitespace_p (EMACS_INT charpos)
{
- int bytepos = CHAR_TO_BYTE (charpos);
+ EMACS_INT bytepos = CHAR_TO_BYTE (charpos);
int c = 0;
while (bytepos < ZV_BYTE
else if (c != 0)
{
int multibyte;
- int bytepos, charpos;
+ EMACS_INT bytepos, charpos;
const unsigned char *spec;
Lisp_Object string;
store_mode_line_string (const char *string, Lisp_Object lisp_string, int copy_string,
int field_width, int precision, Lisp_Object props)
{
- int len;
+ EMACS_INT len;
int n = 0;
if (string != NULL)
case 'i':
{
- int size = ZV - BEGV;
+ EMACS_INT size = ZV - BEGV;
pint2str (decode_mode_spec_buf, field_width, size);
return decode_mode_spec_buf;
}
case 'I':
{
- int size = ZV - BEGV;
+ EMACS_INT size = ZV - BEGV;
pint2hrstr (decode_mode_spec_buf, field_width, size);
return decode_mode_spec_buf;
}
case 'l':
{
- int startpos, startpos_byte, line, linepos, linepos_byte;
- int topline, nlines, junk, height;
+ EMACS_INT startpos, startpos_byte, line, linepos, linepos_byte;
+ int topline, nlines, height;
+ EMACS_INT junk;
/* %c and %l are ignored in `frame-title-format'. */
if (mode_line_target == MODE_LINE_TITLE)
else if (nlines < height + 25 || nlines > height * 3 + 50
|| linepos == BUF_BEGV (b))
{
- int limit = BUF_BEGV (b);
- int limit_byte = BUF_BEGV_BYTE (b);
- int position;
+ EMACS_INT limit = BUF_BEGV (b);
+ EMACS_INT limit_byte = BUF_BEGV_BYTE (b);
+ EMACS_INT position;
int distance = (height * 2 + 30) * line_number_display_limit_width;
if (startpos - distance > limit)
case 'p':
{
- int pos = marker_position (w->start);
- int total = BUF_ZV (b) - BUF_BEGV (b);
+ EMACS_INT pos = marker_position (w->start);
+ EMACS_INT total = BUF_ZV (b) - BUF_BEGV (b);
if (XFASTINT (w->window_end_pos) <= BUF_Z (b) - BUF_ZV (b))
{
so get us a 2-digit number that is close. */
if (total == 100)
total = 99;
- sprintf (decode_mode_spec_buf, "%2d%%", total);
+ sprintf (decode_mode_spec_buf, "%2ld%%", (long)total);
return decode_mode_spec_buf;
}
}
/* Display percentage of size above the bottom of the screen. */
case 'P':
{
- int toppos = marker_position (w->start);
- int botpos = BUF_Z (b) - XFASTINT (w->window_end_pos);
- int total = BUF_ZV (b) - BUF_BEGV (b);
+ EMACS_INT toppos = marker_position (w->start);
+ EMACS_INT botpos = BUF_Z (b) - XFASTINT (w->window_end_pos);
+ EMACS_INT total = BUF_ZV (b) - BUF_BEGV (b);
if (botpos >= BUF_ZV (b))
{
if (total == 100)
total = 99;
if (toppos <= BUF_BEGV (b))
- sprintf (decode_mode_spec_buf, "Top%2d%%", total);
+ sprintf (decode_mode_spec_buf, "Top%2ld%%", (long)total);
else
- sprintf (decode_mode_spec_buf, "%2d%%", total);
+ sprintf (decode_mode_spec_buf, "%2ld%%", (long)total);
return decode_mode_spec_buf;
}
}
Set *BYTE_POS_PTR to 1 if we found COUNT lines, 0 if we hit LIMIT. */
static int
-display_count_lines (int start, int start_byte, int limit_byte, int count,
- int *byte_pos_ptr)
+display_count_lines (EMACS_INT start, EMACS_INT start_byte,
+ EMACS_INT limit_byte, int count,
+ EMACS_INT *byte_pos_ptr)
{
register unsigned char *cursor;
unsigned char *base;
it2 = *it;
if (it->multibyte_p)
- {
- int maxlen = ((IT_BYTEPOS (*it) >= GPT ? ZV : GPT)
- - IT_BYTEPOS (*it));
- it2.c = it2.char_to_display = STRING_CHAR_AND_LENGTH (p, it2.len);
- }
+ it2.c = it2.char_to_display = STRING_CHAR_AND_LENGTH (p, it2.len);
else
{
it2.c = it2.char_to_display = *p, it2.len = 1;
XChar2b char2b;
struct font_metrics *pcm;
int font_not_found_p;
- int pos;
+ EMACS_INT pos;
for (glyph_len = cmp->glyph_len; glyph_len > 0; glyph_len--)
if ((c = COMPOSITION_GLYPH (cmp, glyph_len - 1)) != '\t')
Lisp_Object *overlay_vec = NULL;
int noverlays;
struct buffer *obuf;
- int obegv, ozv, same_region;
+ EMACS_INT obegv, ozv;
+ int same_region;
/* Find the glyph under X/Y. */
glyph = x_y_to_hpos_vpos (w, x, y, &hpos, &vpos, &dx, &dy, &area);
/* If we are on a display string with no mouse-face,
check if the text under it has one. */
struct glyph_row *r = MATRIX_ROW (w->current_matrix, vpos);
- int start = MATRIX_ROW_START_CHARPOS (r);
+ EMACS_INT start = MATRIX_ROW_START_CHARPOS (r);
pos = string_buffer_position (w, object, start);
if (pos > 0)
{
else
{
Lisp_Object object = glyph->object;
- int charpos = glyph->charpos;
+ EMACS_INT charpos = glyph->charpos;
/* Try text properties. */
if (STRINGP (object)
see if the buffer text ``under'' it does. */
struct glyph_row *r
= MATRIX_ROW (w->current_matrix, vpos);
- int start = MATRIX_ROW_START_CHARPOS (r);
+ EMACS_INT start = MATRIX_ROW_START_CHARPOS (r);
EMACS_INT pos = string_buffer_position (w, object, start);
if (pos > 0)
{
if (NILP (pointer))
{
Lisp_Object object = glyph->object;
- int charpos = glyph->charpos;
+ EMACS_INT charpos = glyph->charpos;
/* Try text properties. */
if (STRINGP (object)
see if the buffer text ``under'' it does. */
struct glyph_row *r
= MATRIX_ROW (w->current_matrix, vpos);
- int start = MATRIX_ROW_START_CHARPOS (r);
+ EMACS_INT start = MATRIX_ROW_START_CHARPOS (r);
EMACS_INT pos = string_buffer_position (w, object,
start);
if (pos > 0)