MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / re_insert

Function re_insert

extern/editline/src/refresh.c:358–401  ·  view source on GitHub ↗

re_insert(): * insert num characters of s into d (in front of the character) * at dat, maximum length of d is dlen */

Source from the content-addressed store, hash-verified

356 * at dat, maximum length of d is dlen
357 */
358private void
359/*ARGSUSED*/
360re_insert(EditLine *el __attribute__((__unused__)),
361 Char *d, int dat, int dlen, Char *s, int num)
362{
363 Char *a, *b;
364
365 if (num <= 0)
366 return;
367 if (num > dlen - dat)
368 num = dlen - dat;
369
370 ELRE_DEBUG(1,
371 (__F, "re_insert() starting: %d at %d max %d, d == \"%s\"\n",
372 num, dat, dlen, ct_encode_string(d)));
373 ELRE_DEBUG(1, (__F, "s == \"%s\"\n", ct_encode_string(s)));
374
375 /* open up the space for num chars */
376 if (num > 0) {
377 b = d + dlen - 1;
378 a = b - num;
379 while (a >= &d[dat])
380 *b-- = *a--;
381 d[dlen] = '\0'; /* just in case */
382 }
383
384 ELRE_DEBUG(1, (__F,
385 "re_insert() after insert: %d at %d max %d, d == \"%s\"\n",
386 num, dat, dlen, ct_encode_string(d)));
387 ELRE_DEBUG(1, (__F, "s == \"%s\"\n", ct_encode_string(s)));
388
389 /* copy the characters */
390 for (a = d + dat; (a < d + dlen) && (num > 0); num--)
391 *a++ = *s++;
392
393#ifdef notyet
394 /* ct_encode_string() uses a static buffer, so we can't conveniently
395 * encode both d & s here */
396 ELRE_DEBUG(1,
397 (__F, "re_insert() after copy: %d at %d max %d, %s == \"%s\"\n",
398 num, dat, dlen, d, s));
399 ELRE_DEBUG(1, (__F, "s == \"%s\"\n", s));
400#endif
401}
402
403
404/* re_delete():

Callers 1

re_update_lineFunction · 0.85

Calls 1

ct_encode_stringFunction · 0.85

Tested by

no test coverage detected