text.c 595 B

12345678910111213141516171819202122232425262728293031
  1. /* Text.c - save text string into last_text buffer */
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <grass/gis.h>
  5. #include "driverlib.h"
  6. #include "htmlmap.h"
  7. void HTML_Text(const char *text)
  8. {
  9. int len = strlen(text);
  10. const char *s;
  11. char *d;
  12. if (len > html.last_text_len) {
  13. G_free(html.last_text);
  14. html.last_text = (char *)G_malloc(len + 1);
  15. html.last_text_len = len;
  16. }
  17. /* copy string to last_text area, make sure we don't copy \n */
  18. for (d = html.last_text, s = text; *s != '\0'; s++) {
  19. if (*s != '\n') {
  20. *d = *s;
  21. d++;
  22. }
  23. }
  24. *d = '\0';
  25. }