BRL-CAD
bu_vls.c
Go to the documentation of this file.
1 /* B U _ V L S . C
2  * BRL-CAD
3  *
4  * Copyright (c) 1985-2014 United States Government as represented by
5  * the U.S. Army Research Laboratory.
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public License
9  * version 2.1 as published by the Free Software Foundation.
10  *
11  * This library is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this file; see the file named COPYING for more
18  * information.
19  */
20 
21 #include "common.h"
22 
23 #include <stdlib.h>
24 #include <stdio.h>
25 #include <string.h>
26 
27 #include "bu.h"
28 
29 #include "./vls_internals.h"
30 #include "./test_internals.h"
31 
32 
33 /* This prints out the values of the expected vls and compares it with
34  * the actual vls; it uses the C-style return values of 0 for false and 1
35  * for true
36  */
37 static int
38 compare_vls(struct bu_vls *actual_vls, struct bu_vls *expected_vls)
39 {
40  bu_log("magic: %lu", (unsigned long)expected_vls->vls_magic);
41  bu_log("str: %s", expected_vls->vls_str);
42  bu_log("offset: %lu", (unsigned long)expected_vls->vls_offset);
43  bu_log("len: %lu", (unsigned long)expected_vls->vls_len);
44  bu_log("max: %lu", (unsigned long)expected_vls->vls_max);
45 
46  return (expected_vls->vls_magic == actual_vls->vls_magic
47  && bu_vls_strcmp(expected_vls, actual_vls) == 0);
48 }
49 
50 
51 static int
52 test_bu_vls_init(void)
53 {
54  struct bu_vls expected_vls = { BU_VLS_MAGIC, (char *)0, 0, 0, 0 };
55  struct bu_vls actual_vls;
56 
57  bu_vls_init(&actual_vls);
58 
59  /* These functions need to return sh-style return values where
60  * non-zero is false and zero is true
61  */
62  return !compare_vls(&actual_vls, &expected_vls);
63 }
64 
65 
66 static int
67 test_bu_vls_vlsinit(void)
68 {
69  struct bu_vls expected_vls = { BU_VLS_MAGIC, (char *)0, 0, 0, 0 };
70  struct bu_vls *actual_vls;
71  int retval;
72 
73  actual_vls = bu_vls_vlsinit();
74 
75  /* These functions need to return sh-style return values where
76  * non-zero is false and zero is true
77  */
78  retval = !compare_vls(actual_vls, &expected_vls);
79 
80  bu_vls_free(actual_vls);
81 
82  return retval;
83 }
84 
85 
86 static int
87 test_bu_vls_access(int argc, char *argv[])
88 {
89  char *null_expected_string = "";
90  char *null_actual_string;
91 
92  char *set_expected_string;
93  char *set_actual_addr_string;
94  struct bu_vls vls = BU_VLS_INIT_ZERO;
95  int retval;
96 
97  if (argc != 3) {
98  bu_exit(1, "ERROR: input format is string_to_test [%s]\n", argv[0]);
99  }
100 
101  set_expected_string = argv[2];
102 
103  null_actual_string = bu_vls_addr(&vls);
104  bu_vls_strcpy(&vls, set_expected_string);
105  set_actual_addr_string = bu_vls_addr(&vls);
106 
107  printf("Actual null: %s\n", null_actual_string);
108  printf("Actual addr_string (set): %s\n", set_actual_addr_string);
109 
110  /* These functions need to return sh-style return values where
111  * non-zero is false and zero is true
112  */
113  retval = !(bu_strcmp(null_actual_string, null_expected_string) == 0
114  && bu_strcmp(set_actual_addr_string, set_expected_string) == 0);
115 
116  bu_vls_free(&vls);
117 
118  return retval;
119 }
120 
121 
122 static int
123 test_bu_vls_strncpy(int argc, char *argv[])
124 {
125  char *expected_result_string;
126  char *actual_result_string;
127  int actual_result_len;
128  char *string_orig;
129  char *string_new;
130  int n;
131  struct bu_vls vls = BU_VLS_INIT_ZERO;
132 
133  if (argc != 6) {
134  bu_exit(1, "ERROR: input format is string_orig string_new n expected_result [%s]\n", argv[0]);
135  }
136 
137  string_orig = argv[2];
138  string_new = argv[3];
139  sscanf(argv[4], "%d", &n);
140  expected_result_string = argv[5];
141 
142  bu_vls_strcpy(&vls, string_orig);
143  bu_vls_strncpy(&vls, string_new, n);
144 
145  actual_result_string = bu_vls_strdup(&vls);
146  actual_result_len = bu_vls_strlen(&vls);
147 
148  printf("Result: %s\n", actual_result_string);
149  printf("Result len: %d\n", actual_result_len);
150 
151  bu_vls_free(&vls);
152 
153  /* These functions need to return sh-style return values where
154  * non-zero is false and zero is true
155  */
156  return !(bu_strcmp(actual_result_string, expected_result_string) == 0
157  && actual_result_len == n);
158 }
159 
160 
161 static int
162 test_bu_vls_strdup(int argc, char *argv[])
163 {
164  char *set_expected_string;
165  char *set_actual_strdup_string;
166  struct bu_vls vls = BU_VLS_INIT_ZERO;
167  int retval;
168 
169  if (argc != 3) {
170  bu_exit(1, "ERROR: input format is string_to_test [%s]\n", argv[0]);
171  }
172 
173  set_expected_string = argv[2];
174 
175  bu_vls_strcpy(&vls, set_expected_string);
176  set_actual_strdup_string = bu_vls_strdup(&vls);
177 
178  printf("Actual strdup_string (before free): %s\n", set_actual_strdup_string);
179  retval = bu_strcmp(set_actual_strdup_string, set_expected_string) == 0;
180 
181  bu_vls_free(&vls);
182  printf("Actual strdup_string (after free): %s\n", set_actual_strdup_string);
183  retval = retval && bu_strcmp(set_actual_strdup_string, set_expected_string) == 0;
184 
185  /* These functions need to return sh-style return values where
186  * non-zero is false and zero is true
187  */
188  return !retval;
189 }
190 
191 
192 static int
193 test_bu_vls_strlen(int argc, char *argv[])
194 {
195  char *string;
196  int expected_length;
197  int actual_length;
198  struct bu_vls vls = BU_VLS_INIT_ZERO;
199 
200  if (argc != 3) {
201  bu_exit(1, "ERROR: input format is string_to_test [%s]\n", argv[0]);
202  }
203 
204  string = argv[2];
205  expected_length = strlen(string);
206 
207  bu_vls_strcpy(&vls, string);
208  actual_length = bu_vls_strlen(&vls);
209 
210  bu_vls_free(&vls);
211 
212  /* These functions need to return sh-style return values where
213  * non-zero is false and zero is true
214  */
215  return !(expected_length == actual_length);
216 }
217 
218 
219 static int
220 test_bu_vls_trunc(int argc, char *argv[])
221 {
222  char *in_string;
223  int trunc_len;
224  char *expected_out_string;
225  char *actual_out_string;
226  struct bu_vls vls = BU_VLS_INIT_ZERO;
227 
228  if (argc != 5) {
229  bu_exit(1, "ERROR: input format is string_to_test trunc_len expected_result[%s]\n", argv[0]);
230  }
231 
232  in_string = argv[2];
233  sscanf(argv[3], "%d", &trunc_len);
234  expected_out_string = argv[4];
235 
236  bu_vls_strcpy(&vls, in_string);
237  bu_vls_trunc(&vls, trunc_len);
238  actual_out_string = bu_vls_strdup(&vls);
239 
240  printf("trunc_len: %d\n", trunc_len);
241  printf("Result: %s\n", actual_out_string);
242 
243  bu_vls_free(&vls);
244 
245  /* These functions need to return sh-style return values where
246  * non-zero is false and zero is true
247  */
248  return !(bu_strcmp(actual_out_string, expected_out_string) == 0);
249 }
250 
251 
252 static int
253 test_bu_vls_nibble(int argc, char *argv[])
254 {
255  char *in_string;
256  int nibble_len;
257  char *expected_out_string;
258  char *actual_out_string;
259  struct bu_vls vls = BU_VLS_INIT_ZERO;
260 
261  if (argc != 5) {
262  bu_exit(1, "ERROR: input format is string_to_test nibble_len expected_result[%s]\n", argv[0]);
263  }
264 
265  in_string = argv[2];
266  sscanf(argv[3], "%d", &nibble_len);
267  expected_out_string = argv[4];
268 
269  bu_vls_strcpy(&vls, in_string);
270  bu_vls_nibble(&vls, nibble_len);
271  actual_out_string = bu_vls_strdup(&vls);
272 
273  printf("Result: %s\n", actual_out_string);
274 
275  bu_vls_free(&vls);
276 
277  /* These functions need to return sh-style return values where
278  * non-zero is false and zero is true
279  */
280  return !(bu_strcmp(actual_out_string, expected_out_string) == 0);
281 }
282 
283 
284 static int
285 test_bu_vls_strcat(int argc, char *argv[])
286 {
287  char *in_string_1;
288  char *in_string_2;
289  char *expected_out_string;
290  char *actual_out_string;
291  struct bu_vls vls = BU_VLS_INIT_ZERO;
292 
293  if (argc!= 5) {
294  bu_exit(1, "ERROR: input format is string1 string2 expected_result [%s]\n", argv[0]);
295  }
296 
297  in_string_1 = argv[2];
298  in_string_2 = argv[3];
299  expected_out_string = argv[4];
300 
301  bu_vls_strcpy(&vls, in_string_1);
302  bu_vls_strcat(&vls, in_string_2);
303  actual_out_string = bu_vls_strdup(&vls);
304 
305  printf("Result: %s\n", actual_out_string);
306 
307  bu_vls_free(&vls);
308 
309  /* These functions need to return sh-style return values where
310  * non-zero is false and zero is true
311  */
312  return !(bu_strcmp(actual_out_string, expected_out_string) == 0);
313 }
314 
315 
316 static int
317 test_bu_vls_strncat(int argc, char *argv[])
318 {
319  /* argv[1] is the function number, ignored */
320  char *in_string_1; /* argv[2] */
321  char *in_string_2; /* argv[3] */
322  int n; /* argv[4] */
323  char *expected_out_string; /* argv[5] */
324 
325  int test_results = CTEST_FAIL;
326  struct bu_vls *actual_vls;
327  size_t narg;
328 
329  if (argc != 6) {
330  bu_exit(1, "ERROR: input format is string1 string2 n expected_result [%s]\n", argv[0]);
331  }
332 
333  in_string_1 = argv[2];
334  in_string_2 = argv[3];
335  bu_sscanf(argv[4], "%d", &n);
336  expected_out_string = argv[5];
337 
338  narg = (size_t)n;
339  actual_vls = bu_vls_vlsinit();
340  bu_vls_strcpy(actual_vls, in_string_1);
341  bu_vls_strncat(actual_vls, in_string_2, n);
342 
343  /* These functions need to return sh-style return values where
344  * non-zero is false and zero is true
345  */
346  if (!bu_strcmp(bu_vls_cstr(actual_vls), expected_out_string)) {
347  printf("PASSED Input1: '%s' Input2: '%s' n: %d narg: %u Output: '%s' Expected: '%s'",
348  in_string_1, in_string_2, n, (unsigned int)narg, bu_vls_cstr(actual_vls), expected_out_string);
349  test_results = CTEST_PASS;
350  }
351  else {
352  printf("FAILED Input1: '%s' Input2: '%s' n: %d narg: %u Output: '%s' Expected: '%s'",
353  in_string_1, in_string_2, n, (unsigned int)narg, bu_vls_cstr(actual_vls), expected_out_string);
354  test_results = CTEST_FAIL;
355  }
356 
357  bu_vls_free(actual_vls);
358 
359  return test_results;
360 }
361 
362 
363 static int
364 test_bu_vls_vlscat(int argc, char *argv[])
365 {
366  char *in_string_1;
367  char *in_string_2;
368  char *expected_out_string;
369  char *actual_out_string;
370  struct bu_vls vls_1 = BU_VLS_INIT_ZERO;
371  struct bu_vls vls_2 = BU_VLS_INIT_ZERO;
372 
373  if (argc != 5) {
374  bu_exit(1, "ERROR: input format is string1 string2 expected_result [%s]\n", argv[0]);
375  }
376 
377  in_string_1 = argv[2];
378  in_string_2 = argv[3];
379  expected_out_string = argv[4];
380 
381  bu_vls_strcpy(&vls_1, in_string_1);
382  bu_vls_strcpy(&vls_2, in_string_2);
383  bu_vls_vlscat(&vls_1, &vls_2);
384  actual_out_string = bu_vls_strdup(&vls_1);
385 
386  printf("Result: %s\n", actual_out_string);
387 
388  bu_vls_free(&vls_1);
389  bu_vls_free(&vls_2);
390 
391  /* These functions need to return sh-style return values where
392  * non-zero is false and zero is true
393  */
394  return !(bu_strcmp(actual_out_string, expected_out_string) == 0);
395 }
396 
397 
398 static int
399 test_bu_vls_strcmp(int argc, char *argv[])
400 {
401  char *in_string_1;
402  char *in_string_2;
403  int expected_result;
404  int actual_result;
405  struct bu_vls vls_1 = BU_VLS_INIT_ZERO;
406  struct bu_vls vls_2 = BU_VLS_INIT_ZERO;
407 
408  if (argc != 5) {
409  bu_exit(1, "ERROR: input format is string1 string2 expected_result [%s]\n", argv[0]);
410  }
411 
412  in_string_1 = argv[2];
413  in_string_2 = argv[3];
414  sscanf(argv[4], "%d", &expected_result);
415 
416  bu_vls_strcpy(&vls_1, in_string_1);
417  bu_vls_strcpy(&vls_2, in_string_2);
418  actual_result = bu_vls_strcmp(&vls_1, &vls_2);
419 
420  printf("Result: %d\n", actual_result);
421 
422  bu_vls_free(&vls_1);
423  bu_vls_free(&vls_2);
424 
425  /* These functions need to return sh-style return values where
426  * non-zero is false and zero is true; the condition just checks
427  * that the expected and actual results are on the same side of 0;
428  * it currently expects expected_result to be on of -1, 0, or
429  * 1.
430  */
431  return !(abs(actual_result) == expected_result*actual_result);
432 }
433 
434 
435 static int
436 test_bu_vls_strncmp(int argc, char *argv[])
437 {
438  char *in_string_1;
439  char *in_string_2;
440  int n;
441  int expected_result;
442  int actual_result;
443  struct bu_vls vls_1 = BU_VLS_INIT_ZERO;
444  struct bu_vls vls_2 = BU_VLS_INIT_ZERO;
445 
446  if (argc != 6) {
447  bu_exit(1, "ERROR: input format is string1 string2 n expected_result [%s]\n", argv[0]);
448  }
449 
450  in_string_1 = argv[2];
451  in_string_2 = argv[3];
452  sscanf(argv[4], "%d", &n);
453  sscanf(argv[5], "%d", &expected_result);
454 
455  bu_vls_strcpy(&vls_1, in_string_1);
456  bu_vls_strcpy(&vls_2, in_string_2);
457  actual_result = bu_vls_strncmp(&vls_1, &vls_2, n);
458 
459  printf("Result: %d\n", actual_result);
460 
461  bu_vls_free(&vls_1);
462  bu_vls_free(&vls_2);
463 
464  /* These functions need to return sh-style return values where
465  * non-zero is false and zero is true; the condition just checks
466  * that the expected and actual results are on the same side of 0;
467  * it currently expects expected_result to be on of -1, 0, or
468  * 1.
469  */
470  return !(abs(actual_result) == expected_result*actual_result);
471 }
472 
473 
474 static int
475 test_bu_vls_from_argv(int argc, char *argv[])
476 {
477  char *expected_result;
478  char *actual_result;
479  struct bu_vls vls = BU_VLS_INIT_ZERO;
480 
481  if (argc < 4) {
482  bu_exit(1, "ERROR: input format is strings expected_result [%s]\n", argv[0]);
483  }
484 
485  expected_result = argv[argc-1];
486 
487  bu_vls_from_argv(&vls, argc-3, (const char **)argv+2);
488  actual_result = bu_vls_strdup(&vls);
489 
490  printf("Result: %s\n", actual_result);
491 
492  bu_vls_free(&vls);
493 
494  /* These functions need to return sh-style return values where
495  * non-zero is false and zero is true.
496  */
497  return !(bu_strcmp(actual_result, expected_result) == 0);
498 }
499 
500 
501 static int
502 test_bu_vls_trimspace(int argc, char *argv[])
503 {
504  char *in_string;
505  char *expected_result;
506  char *actual_result;
507  struct bu_vls vls = BU_VLS_INIT_ZERO;
508 
509  if (argc != 4) {
510  bu_exit(1, "ERROR: input format is string expected_result [%s]\n", argv[0]);
511  }
512 
513  in_string = argv[2];
514  expected_result = argv[3];
515 
516  bu_vls_strcpy(&vls, in_string);
517  bu_vls_trimspace(&vls);
518 
519  actual_result = bu_vls_strdup(&vls);
520 
521  printf("Result: %s\n", actual_result);
522 
523  bu_vls_free(&vls);
524 
525  /* These functions need to return sh-style return values where
526  * non-zero is false and zero is true.
527  */
528  return !(bu_strcmp(actual_result, expected_result) == 0);
529 }
530 
531 
532 static int
533 test_bu_vls_spaces(int argc, char *argv[])
534 {
535  char *in_string;
536  int num_spaces;
537  char *expected_result;
538  char *actual_result;
539  struct bu_vls vls = BU_VLS_INIT_ZERO;
540 
541  if (argc != 5) {
542  bu_exit(1, "ERROR: input format is string num_spaces expected_result [%s]\n", argv[0]);
543  }
544 
545  in_string = argv[2];
546  sscanf(argv[3], "%d", &num_spaces);
547  expected_result = argv[4];
548 
549  bu_vls_strcpy(&vls, in_string);
550  bu_vls_spaces(&vls, num_spaces);
551 
552  actual_result = bu_vls_strdup(&vls);
553 
554  printf("Result: %s\n", actual_result);
555 
556  bu_vls_free(&vls);
557 
558  /* These functions need to return sh-style return values where
559  * non-zero is false and zero is true.
560  */
561  return !(bu_strcmp(actual_result, expected_result) == 0);
562 }
563 
564 
565 static int
566 test_bu_vls_detab(int argc, char *argv[])
567 {
568  char *in_string;
569  char *expected_result;
570  char *actual_result;
571  struct bu_vls vls = BU_VLS_INIT_ZERO;
572 
573  if (argc != 4) {
574  bu_exit(1, "ERROR: input format is string expected_result [%s]\n", argv[0]);
575  }
576 
577  in_string = argv[2];
578  expected_result = argv[3];
579 
580  bu_vls_strcpy(&vls, in_string);
581  bu_vls_detab(&vls);
582 
583  actual_result = bu_vls_strdup(&vls);
584 
585  printf("Result: %s\n", actual_result);
586 
587  bu_vls_free(&vls);
588 
589  /* These functions need to return sh-style return values where
590  * non-zero is false and zero is true.
591  */
592  return !(bu_strcmp(actual_result, expected_result) == 0);
593 }
594 
595 
596 static int
597 test_bu_vls_prepend(int argc, char *argv[])
598 {
599  char *in_string;
600  char *prepend_string;
601  char *expected_result;
602  char *actual_result;
603  struct bu_vls vls = BU_VLS_INIT_ZERO;
604 
605  if (argc != 5) {
606  bu_exit(1, "ERROR: input format is string string_to_prepend expected_result[%s]\n", argv[0]);
607  }
608 
609  in_string = argv[2];
610  prepend_string= argv[3];
611  expected_result = argv[4];
612 
613  bu_vls_strcpy(&vls, in_string);
614  bu_vls_prepend(&vls, prepend_string);
615 
616  actual_result = bu_vls_strdup(&vls);
617 
618  printf("Result: %s\n", actual_result);
619 
620  bu_vls_free(&vls);
621 
622  /* These functions need to return sh-style return values where
623  * non-zero is false and zero is true.
624  */
625  return !(bu_strcmp(actual_result, expected_result) == 0);
626 }
627 
628 
629 static int
630 test_bu_vls_substr(int argc, char **argv)
631 {
632  /* argv[1] argv[2] argv[3] argv[4] argv[5]
633  * inputs: <func num> <src string> <substr index> <substr len> <expected string>
634  */
635  const char *src_string = argv[2];
636  size_t begin = (size_t)atoi(argv[3]);
637  size_t slen = (size_t)atoi(argv[4]);
638  const char *expected_result = argv[5];
639 
640  struct bu_vls vsrc = BU_VLS_INIT_ZERO;
641  struct bu_vls vsubstr = BU_VLS_INIT_ZERO;
642  int test_results = CTEST_FAIL;
643 
644  /* CMake won't pass empty strings as test parameters properly;
645  * assume expected_result is supposed to be empty.
646  */
647  if (argc == 5) {
648  expected_result = "";
649  argc++;
650  }
651 
652  if (argc != 6)
653  bu_exit(1, "ERROR: input format is <func num> <source string> <begin index> <num chars> <expected result string> [%s]\n", argv[0]);
654 
655  bu_vls_strcpy(&vsrc, src_string);
656 
657  bu_vls_substr(&vsubstr, &vsrc, begin, slen);
658 
659  if (BU_STR_EQUAL(bu_vls_cstr(&vsubstr), expected_result)) {
660  test_results = CTEST_PASS;
661  printf("\nbu_vls_substr PASSED");
662  } else {
663  test_results = CTEST_FAIL;
664  printf("\nbu_vls_substr FAILED");
665  }
666  printf("\n Input: '%s'", bu_vls_cstr(&vsrc));
667  printf("\n Output: '%s'", bu_vls_cstr(&vsubstr));
668  printf("\n Expected: '%s'", expected_result);
669 
670  bu_vls_free(&vsrc);
671  bu_vls_free(&vsubstr);
672 
673  return test_results;
674 }
675 
676 
677 int
678 main(int argc, char *argv[])
679 {
680  int function_num = 0;
681 
682  if (argc < 2) {
683  bu_exit(1, "ERROR: input format is function_num function_test_args [%s]\n", argv[0]);
684  }
685 
686  sscanf(argv[1], "%d", &function_num);
687 
688  switch (function_num) {
689  case 1:
690  /* We don't need any arguments here, as there is only one
691  * thing that bu_vls_init can do
692  */
693  return test_bu_vls_init();
694  case 2:
695  /* We don't need any arguments here, as there is only one
696  * thing that bu_vls_init can do
697  */
698  return test_bu_vls_vlsinit();
699  case 3:
700  return test_bu_vls_access(argc, argv);
701  case 4:
702  return test_bu_vls_strncpy(argc, argv);
703  case 5:
704  return test_bu_vls_strdup(argc, argv);
705  case 6:
706  return test_bu_vls_strlen(argc, argv);
707  case 7:
708  return test_bu_vls_trunc(argc, argv);
709  case 8:
710  return 0; /* deprecation removal */
711  case 9:
712  return test_bu_vls_nibble(argc, argv);
713  case 10:
714  return test_bu_vls_strcat(argc, argv);
715  case 11:
716  return test_bu_vls_strncat(argc, argv);
717  case 12:
718  return test_bu_vls_vlscat(argc, argv);
719  case 13:
720  return test_bu_vls_strcmp(argc, argv);
721  case 14:
722  return test_bu_vls_strncmp(argc, argv);
723  case 15:
724  return test_bu_vls_from_argv(argc, argv);
725  case 16:
726  return test_bu_vls_trimspace(argc, argv);
727  case 17:
728  return test_bu_vls_spaces(argc, argv);
729  case 18:
730  return test_bu_vls_detab(argc, argv);
731  case 19:
732  return test_bu_vls_prepend(argc, argv);
733  case 20:
734  return test_bu_vls_substr(argc, argv);
735  }
736 
737  bu_log("ERROR: function_num %d is not valid [%s]\n", function_num, argv[0]);
738  return 1;
739 }
740 
741 
742 /*
743  * Local Variables:
744  * mode: C
745  * tab-width: 8
746  * indent-tabs-mode: t
747  * c-file-style: "stroustrup"
748  * End:
749  * ex: shiftwidth=4 tabstop=8
750  */
void bu_vls_init(struct bu_vls *vp)
Definition: vls.c:56
void bu_log(const char *,...) _BU_ATTR_PRINTF12
Definition: log.c:176
void bu_vls_strncat(struct bu_vls *vp, const char *s, size_t n)
Definition: vls.c:390
uint32_t vls_magic
Definition: vls.h:57
void bu_vls_strcat(struct bu_vls *vp, const char *s)
Definition: vls.c:368
void bu_vls_trunc(struct bu_vls *vp, int len)
Definition: vls.c:198
void bu_vls_nibble(struct bu_vls *vp, off_t len)
Definition: vls.c:217
void bu_vls_strncpy(struct bu_vls *vp, const char *s, size_t n)
Definition: vls.c:339
Header file for the BRL-CAD common definitions.
size_t vls_len
Definition: vls.h:60
int main(int argc, char *argv[])
Definition: bu_vls.c:678
const int CTEST_FAIL
void bu_vls_free(struct bu_vls *vp)
Definition: vls.c:248
void bu_exit(int status, const char *fmt,...) _BU_ATTR_NORETURN _BU_ATTR_PRINTF23
Definition: bomb.c:195
void bu_vls_from_argv(struct bu_vls *vp, int argc, const char *argv[])
Definition: vls.c:532
int bu_sscanf(const char *src, const char *fmt,...) _BU_ATTR_SCANF23
Definition: sscanf.c:676
size_t bu_vls_strlen(const struct bu_vls *vp)
Definition: vls.c:189
char * bu_vls_strdup(const struct bu_vls *vp)
Definition: vls.c:274
struct bu_vls * bu_vls_vlsinit(void)
Definition: vls.c:91
const char * bu_vls_cstr(const struct bu_vls *vp)
Definition: vls.c:103
char * bu_vls_addr(const struct bu_vls *vp)
Definition: vls.c:111
size_t vls_offset
Definition: vls.h:59
int bu_strcmp(const char *string1, const char *string2)
Definition: str.c:171
int bu_vls_strncmp(struct bu_vls *s1, struct bu_vls *s2, size_t n)
Definition: vls.c:505
char * vls_str
Definition: vls.h:58
int bu_vls_strcmp(struct bu_vls *s1, struct bu_vls *s2)
Definition: vls.c:482
void bu_vls_substr(struct bu_vls *dest, const struct bu_vls *src, size_t begin, size_t nchars)
Definition: vls.c:447
void bu_vls_trimspace(struct bu_vls *vp)
Definition: vls.c:678
void bu_vls_strcpy(struct bu_vls *vp, const char *s)
Definition: vls.c:310
void bu_vls_spaces(struct bu_vls *vp, size_t cnt)
Definition: vls.c:721
#define BU_VLS_INIT_ZERO
Definition: vls.h:84
void bu_vls_prepend(struct bu_vls *vp, char *str)
Definition: vls.c:796
#define BU_VLS_MAGIC
Definition: magic.h:65
void bu_vls_vlscat(struct bu_vls *dest, const struct bu_vls *src)
Definition: vls.c:415
size_t vls_max
Definition: vls.h:61
Definition: vls.h:56
void bu_vls_detab(struct bu_vls *vp)
Definition: vls.c:762
const int CTEST_PASS
#define BU_STR_EQUAL(s1, s2)
Definition: str.h:126