diff options
author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2023-02-28 14:12:09 -0800 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2023-02-28 14:12:09 -0800 |
commit | f7246b984c287b64eb73ee0c303f1b61ee51caf2 (patch) | |
tree | 845c12f885a5754f43516aba001988873f12b98e | |
parent | 02d6fcb26ee1c77c26d98372898d0e48542da5cb (diff) |
Replace calls to index() with strchr()
Use C standard API instead of old BSD equivalent
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
-rw-r--r-- | src/Label.c | 12 | ||||
-rw-r--r-- | src/Tip.c | 16 |
2 files changed, 14 insertions, 14 deletions
diff --git a/src/Label.c b/src/Label.c index 4c95d42..cec1875 100644 --- a/src/Label.c +++ b/src/Label.c @@ -305,12 +305,12 @@ SetTextWidthAndHeight(LabelWidget lw) lw->label.label_len = 0; lw->label.label_width = 0; } - else if ((nl = index(lw->label.label, '\n')) != NULL) { + else if ((nl = strchr(lw->label.label, '\n')) != NULL) { char *label; lw->label.label_len = MULTI_LINE_LABEL; lw->label.label_width = 0; - for (label = lw->label.label; nl != NULL; nl = index(label, '\n')) { + for (label = lw->label.label; nl != NULL; nl = strchr(label, '\n')) { int width = XmbTextEscapement(fset, label, (int)(nl - label)); if (width > (int)lw->label.label_width) @@ -338,12 +338,12 @@ SetTextWidthAndHeight(LabelWidget lw) lw->label.label_len = 0; lw->label.label_width = 0; } - else if ((nl = index(lw->label.label, '\n')) != NULL) { + else if ((nl = strchr(lw->label.label, '\n')) != NULL) { char *label; lw->label.label_len = MULTI_LINE_LABEL; lw->label.label_width = 0; - for (label = lw->label.label; nl != NULL; nl = index(label, '\n')) { + for (label = lw->label.label; nl != NULL; nl = strchr(label, '\n')) { int width; if (lw->label.encoding) @@ -537,7 +537,7 @@ XawLabelRedisplay(Widget gw, XEvent *event, Region region) if (len == MULTI_LINE_LABEL) { char *nl; - while ((nl = index(label, '\n')) != NULL) { + while ((nl = strchr(label, '\n')) != NULL) { XmbDrawString(XtDisplay(w), XtWindow(w), w->label.fontset, gc, w->label.label_x, ksy, label, (int)(nl - label)); @@ -554,7 +554,7 @@ XawLabelRedisplay(Widget gw, XEvent *event, Region region) if (len == MULTI_LINE_LABEL) { char *nl; - while ((nl = index(label, '\n')) != NULL) { + while ((nl = strchr(label, '\n')) != NULL) { if (w->label.encoding) XDrawString16(XtDisplay(gw), XtWindow(gw), gc, w->label.label_x, y, @@ -332,7 +332,7 @@ XawTipExpose(Widget w, XEvent *event, Region region) ksy = (ksy + XawAbs(ext->max_ink_extent.y)); - while ((nl = index(label, '\n')) != NULL) { + while ((nl = strchr(label, '\n')) != NULL) { XmbDrawString(XtDisplay(w), XtWindow(w), tip->tip.fontset, gc, tip->tip.left_margin, ksy, label, (int)(nl - label)); @@ -345,7 +345,7 @@ XawTipExpose(Widget w, XEvent *event, Region region) tip->tip.left_margin, ksy, label, len); } else { - while ((nl = index(label, '\n')) != NULL) { + while ((nl = strchr(label, '\n')) != NULL) { if (tip->tip.encoding) XDrawString16(XtDisplay(w), XtWindow(w), gc, tip->tip.left_margin, y, @@ -411,7 +411,7 @@ TipLayout(XawTipInfo *info) XFontSetExtents *ext = XExtentsOfFontSet(fset); height = ext->max_ink_extent.height; - if ((nl = index(label, '\n')) != NULL) { + if ((nl = strchr(label, '\n')) != NULL) { /*CONSTCOND*/ while (True) { int w = XmbTextEscapement(fset, label, (int)(nl - label)); @@ -423,8 +423,8 @@ TipLayout(XawTipInfo *info) label = nl + 1; if (*label) height += ext->max_ink_extent.height; - if ((nl = index(label, '\n')) == NULL) - nl = index(label, '\0'); + if ((nl = strchr(label, '\n')) == NULL) + nl = strchr(label, '\0'); } } else @@ -432,7 +432,7 @@ TipLayout(XawTipInfo *info) } else { height = fs->max_bounds.ascent + fs->max_bounds.descent; - if ((nl = index(label, '\n')) != NULL) { + if ((nl = strchr(label, '\n')) != NULL) { /*CONSTCOND*/ while (True) { int w = info->tip->tip.encoding ? @@ -445,8 +445,8 @@ TipLayout(XawTipInfo *info) label = nl + 1; if (*label) height += fs->max_bounds.ascent + fs->max_bounds.descent; - if ((nl = index(label, '\n')) == NULL) - nl = index(label, '\0'); + if ((nl = strchr(label, '\n')) == NULL) + nl = strchr(label, '\0'); } } else |