~ubuntu-branches/debian/sid/freeciv/sid

« back to all changes in this revision

Viewing changes to common/featured_text.c

  • Committer: Package Import Robot
  • Author(s): Clint Adams, Karl Goetz, Clint Adams
  • Date: 2011-08-28 22:40:00 UTC
  • mfrom: (1.2.19 upstream)
  • Revision ID: package-import@ubuntu.com-20110828224000-j2r1erewlem25dox
Tags: 2.3.0-1
[ Karl Goetz ]
* New upstream version.
* Fix themes_sdl_use_system_fonts.diff to apply cleanly on 2.3.0
* Massage work_around_unity_induced_breakage.diff to get it
  applying to the new codebase (The patch assumes commits made
  after 2.3.0 was tagged upstream).

[ Clint Adams ]
* Fudge build system to think there is no libtool mismatch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
#define SEQ_END '/'
39
39
 
40
40
#define MAX_LEN_STR 32
41
 
#define LOG_FEATURED_TEXT LOG_VERBOSE
 
41
#define log_featured_text log_verbose
42
42
 
43
43
#define text_tag_list_rev_iterate(tags, ptag) \
44
44
  TYPED_LIST_ITERATE_REV(struct text_tag, tags, ptag)
69
69
};
70
70
 
71
71
/* Predefined colors. */
72
 
#define FT_COLOR(fg, bg) { .foreground = fg, .background = bg }
73
72
const struct ft_color ftc_any           = FT_COLOR(NULL,        NULL);
74
73
 
75
74
const struct ft_color ftc_warning       = FT_COLOR("#FF0000",   NULL);
94
93
const struct ft_color ftc_vote_yes      = FT_COLOR("#000000",   "#C8FFD5");
95
94
const struct ft_color ftc_vote_no       = FT_COLOR("#000000",   "#FFD2D2");
96
95
const struct ft_color ftc_vote_abstain  = FT_COLOR("#000000",   "#E8E8E8");
97
 
#undef FT_COLOR
98
 
 
99
96
 
100
97
/**************************************************************************
101
98
  Return the long name of the text tag type.
172
169
  size_t option_len = strlen(option);
173
170
 
174
171
  while (*read != '\0') {
175
 
    while (my_isspace(*read) && *read != '\0') {
 
172
    while (fc_isspace(*read) && *read != '\0') {
176
173
      read++;
177
174
    }
178
175
 
180
177
      /* This is this one. */
181
178
      read += option_len;
182
179
 
183
 
      while ((my_isspace(*read) || *read == '=') && *read != '\0') {
 
180
      while ((fc_isspace(*read) || *read == '=') && *read != '\0') {
184
181
        read++;
185
182
      }
186
183
      if (*read == '"') {
191
188
          return FALSE;
192
189
        }
193
190
        if (end - read + 1 > 0) {
194
 
          mystrlcpy(write, read, MIN(end - read + 1, write_len));
 
191
          fc_strlcpy(write, read, MIN(end - read + 1, write_len));
195
192
        } else {
196
193
          *write = '\0';
197
194
        }
198
195
        return TRUE;
199
196
      } else {
200
 
        while (my_isalnum(*read) && write_len > 1) {
 
197
        while (fc_isalnum(*read) && write_len > 1) {
201
198
          *write++ = *read++;
202
199
          write_len--;
203
200
        }
254
251
 
255
252
      if (!find_option(sequence, "target", buf, sizeof(buf))
256
253
          && !find_option(sequence, "tgt", buf, sizeof(buf))) {
257
 
        freelog(LOG_FEATURED_TEXT,
258
 
                "text_tag_init_from_sequence: target link type not set.");
 
254
        log_featured_text("text_tag_init_from_sequence(): "
 
255
                          "target link type not set.");
259
256
        return FALSE;
260
257
      }
261
258
 
262
259
      ptag->link.type = -1;
263
260
      for (i = 0; (name = text_link_type_name(i)); i++) {
264
 
        if (0 == mystrncasecmp(buf, name, strlen(name))) {
 
261
        if (0 == fc_strncasecmp(buf, name, strlen(name))) {
265
262
          ptag->link.type = i;
266
263
          break;
267
264
        }
268
265
      }
269
266
      if (ptag->link.type == -1) {
270
 
        freelog(LOG_FEATURED_TEXT, "text_tag_init_from_sequence: "
271
 
                "target link type not supported (\"%s\").", buf);
 
267
        log_featured_text("text_tag_init_from_sequence(): "
 
268
                          "target link type not supported (\"%s\").", buf);
272
269
        return FALSE;
273
270
      }
274
271
 
276
273
      case TLT_CITY:
277
274
        {
278
275
          if (!find_option(sequence, "id", buf, sizeof(buf))) {
279
 
            freelog(LOG_FEATURED_TEXT,
280
 
                    "text_tag_init_from_sequence: city link without id.");
 
276
            log_featured_text("text_tag_init_from_sequence(): "
 
277
                              "city link without id.");
281
278
            return FALSE;
282
279
          }
283
 
          if (1 != sscanf(buf, "%d", &ptag->link.id)) {
284
 
            freelog(LOG_FEATURED_TEXT, "text_tag_init_from_sequence: "
285
 
                    "city link without valid id (\"%s\").", buf);
 
280
          if (!str_to_int(buf, &ptag->link.id)) {
 
281
            log_featured_text("text_tag_init_from_sequence(): "
 
282
                              "city link without valid id (\"%s\").", buf);
286
283
            return FALSE;
287
284
          }
288
285
 
289
286
          if (!find_option(sequence, "name", ptag->link.name,
290
287
                           sizeof(ptag->link.name))) {
291
288
            /* Set something as name. */
292
 
            my_snprintf(ptag->link.name, sizeof(ptag->link.name),
 
289
            fc_snprintf(ptag->link.name, sizeof(ptag->link.name),
293
290
                        "CITY_ID%d", ptag->link.id);
294
291
          }
295
292
        }
300
297
          int x, y;
301
298
 
302
299
          if (!find_option(sequence, "x", buf, sizeof(buf))) {
303
 
            freelog(LOG_FEATURED_TEXT, "text_tag_init_from_sequence: "
304
 
                    "tile link without x coordinate.");
 
300
            log_featured_text("text_tag_init_from_sequence(): "
 
301
                              "tile link without x coordinate.");
305
302
            return FALSE;
306
303
          }
307
 
          if (1 != sscanf(buf, "%d", &x)) {
308
 
            freelog(LOG_FEATURED_TEXT, "text_tag_init_from_sequence: "
309
 
                    "tile link without valid x coordinate (\"%s\").", buf);
 
304
          if (!str_to_int(buf, &x)) {
 
305
            log_featured_text("text_tag_init_from_sequence(): "
 
306
                              "tile link without valid x coordinate "
 
307
                              "(\"%s\").", buf);
310
308
            return FALSE;
311
309
          }
312
310
 
313
311
          if (!find_option(sequence, "y", buf, sizeof(buf))) {
314
 
            freelog(LOG_FEATURED_TEXT, "text_tag_init_from_sequence: "
315
 
                    "tile link without y coordinate.");
 
312
            log_featured_text("text_tag_init_from_sequence(): "
 
313
                              "tile link without y coordinate.");
316
314
            return FALSE;
317
315
          }
318
 
          if (1 != sscanf(buf, "%d", &y)) {
319
 
            freelog(LOG_FEATURED_TEXT, "text_tag_init_from_sequence: "
320
 
                    "tile link without valid y coordinate (\"%s\").", buf);
 
316
          if (!str_to_int(buf, &y)) {
 
317
            log_featured_text("text_tag_init_from_sequence(): "
 
318
                              "tile link without valid y coordinate "
 
319
                              "(\"%s\").", buf);
321
320
            return FALSE;
322
321
          }
323
322
 
324
323
          ptile = map_pos_to_tile(x, y);
325
324
          if (!ptile) {
326
 
            freelog(LOG_FEATURED_TEXT, "text_tag_init_from_sequence: "
327
 
                    "(%d, %d) are not valid coordinates in this game.",
328
 
                    x, y);
 
325
            log_featured_text("text_tag_init_from_sequence(): "
 
326
                              "(%d, %d) are not valid coordinates "
 
327
                              "in this game.", x, y);
329
328
            return FALSE;
330
329
          }
331
330
          ptag->link.id = tile_index(ptile);
332
 
          my_snprintf(ptag->link.name, sizeof(ptag->link.name),
 
331
          fc_snprintf(ptag->link.name, sizeof(ptag->link.name),
333
332
                      "(%d, %d)", TILE_XY(ptile));
334
333
        }
335
334
        return TRUE;
336
335
      case TLT_UNIT:
337
336
        {
338
337
          if (!find_option(sequence, "id", buf, sizeof(buf))) {
339
 
            freelog(LOG_FEATURED_TEXT,
340
 
                    "text_tag_init_from_sequence: unit link without id.");
 
338
            log_featured_text("text_tag_init_from_sequence(): "
 
339
                              "unit link without id.");
341
340
            return FALSE;
342
341
          }
343
 
          if (1 != sscanf(buf, "%d", &ptag->link.id)) {
344
 
            freelog(LOG_FEATURED_TEXT, "text_tag_init_from_sequence: "
345
 
                    "unit link without valid id (\"%s\").", buf);
 
342
          if (!str_to_int(buf, &ptag->link.id)) {
 
343
            log_featured_text("text_tag_init_from_sequence(): "
 
344
                              "unit link without valid id (\"%s\").", buf);
346
345
            return FALSE;
347
346
          }
348
347
 
349
348
          if (!find_option(sequence, "name", ptag->link.name,
350
349
                           sizeof(ptag->link.name))) {
351
350
            /* Set something as name. */
352
 
            my_snprintf(ptag->link.name, sizeof(ptag->link.name),
 
351
            fc_snprintf(ptag->link.name, sizeof(ptag->link.name),
353
352
                        "UNIT_ID%d", ptag->link.id);
354
353
          }
355
354
        }
436
435
            return FALSE;
437
436
          }
438
437
          ptag->link.id = tile_index(ptile);
439
 
          my_snprintf(ptag->link.name, sizeof(ptag->link.name),
 
438
          fc_snprintf(ptag->link.name, sizeof(ptag->link.name),
440
439
                      "(%d, %d)", TILE_XY(ptile));
441
440
        }
442
441
        return TRUE;
468
467
  case TTT_ITALIC:
469
468
  case TTT_STRIKE:
470
469
  case TTT_UNDERLINE:
471
 
    return my_snprintf(buf, len, "%c%s%c", SEQ_START,
 
470
    return fc_snprintf(buf, len, "%c%s%c", SEQ_START,
472
471
                       text_tag_type_short_name(ptag->type), SEQ_STOP);
473
472
  case TTT_COLOR:
474
473
    {
475
 
      size_t ret = my_snprintf(buf, len, "%c%s", SEQ_START,
 
474
      size_t ret = fc_snprintf(buf, len, "%c%s", SEQ_START,
476
475
                               text_tag_type_short_name(ptag->type));
477
476
 
478
477
      if (ptag->color.foreground[0] != '\0') {
479
 
        ret += my_snprintf(buf + ret, len - ret, " fg=\"%s\"",
 
478
        ret += fc_snprintf(buf + ret, len - ret, " fg=\"%s\"",
480
479
                           ptag->color.foreground);
481
480
      }
482
481
      if (ptag->color.background[0] != '\0') {
483
 
        ret += my_snprintf(buf + ret, len - ret, " bg=\"%s\"",
 
482
        ret += fc_snprintf(buf + ret, len - ret, " bg=\"%s\"",
484
483
                           ptag->color.background);
485
484
      }
486
 
      return ret + my_snprintf(buf + ret, len - ret, "%c", SEQ_STOP);
 
485
      return ret + fc_snprintf(buf + ret, len - ret, "%c", SEQ_STOP);
487
486
    }
488
487
  case TTT_LINK:
489
488
    {
490
 
      size_t ret = my_snprintf(buf, len, "%c%s tgt=\"%s\"", SEQ_START,
 
489
      size_t ret = fc_snprintf(buf, len, "%c%s tgt=\"%s\"", SEQ_START,
491
490
                               text_tag_type_short_name(ptag->type),
492
491
                               text_link_type_name(ptag->link.type));
493
492
 
494
493
      switch (ptag->link.type) {
495
494
      case TLT_CITY:
496
495
        {
497
 
          struct city *pcity = game_find_city_by_number(ptag->link.id);
 
496
          struct city *pcity = game_city_by_number(ptag->link.id);
498
497
 
499
498
          if (pcity) {
500
 
            ret += my_snprintf(buf + ret, len - ret,
 
499
            ret += fc_snprintf(buf + ret, len - ret,
501
500
                               " id=%d name=\"%s\"",
502
501
                               pcity->id, city_name(pcity));
503
502
          } else {
504
 
            ret += my_snprintf(buf + ret, len - ret,
 
503
            ret += fc_snprintf(buf + ret, len - ret,
505
504
                               " id=%d", ptag->link.id);
506
505
          }
507
506
        }
511
510
          struct tile *ptile = index_to_tile(ptag->link.id);
512
511
 
513
512
          if (ptile) {
514
 
            ret += my_snprintf(buf + ret, len - ret,
 
513
            ret += fc_snprintf(buf + ret, len - ret,
515
514
                               " x=%d y=%d", TILE_XY(ptile));
516
515
          } else {
517
 
            ret += my_snprintf(buf + ret, len - ret,
 
516
            ret += fc_snprintf(buf + ret, len - ret,
518
517
                               " id=%d", ptag->link.id);
519
518
          }
520
519
        }
521
520
        break;
522
521
      case TLT_UNIT:
523
522
        {
524
 
          struct unit *punit = game_find_unit_by_number(ptag->link.id);
 
523
          struct unit *punit = game_unit_by_number(ptag->link.id);
525
524
 
526
525
          if (punit) {
527
 
            ret += my_snprintf(buf + ret, len - ret,
 
526
            ret += fc_snprintf(buf + ret, len - ret,
528
527
                               " id=%d name=\"%s\"",
529
528
                               punit->id, unit_rule_name(punit));
530
529
          } else {
531
 
            ret += my_snprintf(buf + ret, len - ret,
 
530
            ret += fc_snprintf(buf + ret, len - ret,
532
531
                               " id=%d", ptag->link.id);
533
532
          }
534
533
        }
537
536
 
538
537
      if (ptag->stop_offset == ptag->start_offset) {
539
538
        /* This is a single sequence like [link ... /]. */
540
 
        ret += my_snprintf(buf + ret, len - ret, "%c", SEQ_END);
 
539
        ret += fc_snprintf(buf + ret, len - ret, "%c", SEQ_END);
541
540
      }
542
541
 
543
 
      return ret + my_snprintf(buf + ret, len - ret, "%c", SEQ_STOP);
 
542
      return ret + fc_snprintf(buf + ret, len - ret, "%c", SEQ_STOP);
544
543
    }
545
544
  };
546
545
  return 0;
557
556
    return 0;
558
557
  }
559
558
 
560
 
  return my_snprintf(buf, len, "%c%c%s%c", SEQ_START, SEQ_END,
 
559
  return fc_snprintf(buf, len, "%c%c%s%c", SEQ_START, SEQ_END,
561
560
                     text_tag_type_short_name(ptag->type), SEQ_STOP);
562
561
}
563
562
 
576
575
    switch (ptag->link.type) {
577
576
    case TLT_CITY:
578
577
      {
579
 
        struct city *pcity = game_find_city_by_number(ptag->link.id);
 
578
        struct city *pcity = game_city_by_number(ptag->link.id);
580
579
 
581
580
        /* Note that if city_tile(pcity) is NULL, then it is probably an
582
581
         * invisible city (see client/packhand.c).  Then, we don't
583
582
         * use the current city name which is usually not complete,
584
583
         * a dumb string using the city id. */
585
584
        if (NULL != pcity && NULL != city_tile(pcity)) {
586
 
          return my_snprintf(buf, len, "%s", city_name(pcity));
 
585
          return fc_snprintf(buf, len, "%s", city_name(pcity));
587
586
        }
588
587
      }
589
588
      break;
591
590
      break;
592
591
    case TLT_UNIT:
593
592
      {
594
 
        struct unit *punit = game_find_unit_by_number(ptag->link.id);
 
593
        struct unit *punit = game_unit_by_number(ptag->link.id);
595
594
 
596
595
        if (punit) {
597
 
          return my_snprintf(buf, len, "%s", unit_name_translation(punit));
 
596
          return fc_snprintf(buf, len, "%s", unit_name_translation(punit));
598
597
        }
599
598
      }
600
599
      break;
603
602
 
604
603
  if (ptag->link.type == TLT_UNIT) {
605
604
    /* Attempt to translate the link name (it should be a unit type name). */
606
 
    return my_snprintf(buf, len, "%s", _(ptag->link.name));
 
605
    return fc_snprintf(buf, len, "%s", _(ptag->link.name));
607
606
  } else {
608
 
    return my_snprintf(buf, len, "%s", ptag->link.name);
 
607
    return fc_snprintf(buf, len, "%s", ptag->link.name);
609
608
  }
610
609
}
611
610
 
648
647
}
649
648
 
650
649
/**************************************************************************
 
650
  This function returns a new pointer to a text_tag which is similar
 
651
  to the 'ptag' argument.
 
652
**************************************************************************/
 
653
struct text_tag *text_tag_copy(const struct text_tag *ptag)
 
654
{
 
655
  struct text_tag *pnew_tag;
 
656
 
 
657
  if (!ptag) {
 
658
    return NULL;
 
659
  }
 
660
 
 
661
  pnew_tag = fc_malloc(sizeof(struct text_tag));
 
662
  *pnew_tag = *ptag;
 
663
 
 
664
  return pnew_tag;
 
665
}
 
666
 
 
667
/**************************************************************************
651
668
  Free a text_tag structure.
652
669
**************************************************************************/
653
670
void text_tag_destroy(struct text_tag *ptag)
686
703
const char *text_tag_color_foreground(const struct text_tag *ptag)
687
704
{
688
705
  if (ptag->type != TTT_COLOR) {
689
 
    freelog(LOG_ERROR, "text_tag_color_foreground: incompatible tag type.");
 
706
    log_error("text_tag_color_foreground(): incompatible tag type.");
690
707
    return NULL;
691
708
  }
692
709
 
700
717
const char *text_tag_color_background(const struct text_tag *ptag)
701
718
{
702
719
  if (ptag->type != TTT_COLOR) {
703
 
    freelog(LOG_ERROR, "text_tag_color_background: incompatible tag type.");
 
720
    log_error("text_tag_color_background(): incompatible tag type.");
704
721
    return NULL;
705
722
  }
706
723
 
714
731
enum text_link_type text_tag_link_type(const struct text_tag *ptag)
715
732
{
716
733
  if (ptag->type != TTT_LINK) {
717
 
    freelog(LOG_ERROR, "text_tag_link_type: incompatible tag type.");
 
734
    log_error("text_tag_link_type(): incompatible tag type.");
718
735
    return -1;
719
736
  }
720
737
 
729
746
int text_tag_link_id(const struct text_tag *ptag)
730
747
{
731
748
  if (ptag->type != TTT_LINK) {
732
 
    freelog(LOG_ERROR, "text_tag_link_id: incompatible tag type.");
 
749
    log_error("text_tag_link_id(): incompatible tag type.");
733
750
    return -1;
734
751
  }
735
752
 
737
754
}
738
755
 
739
756
/**************************************************************************
740
 
  Clear and free all tags inside the tag list.  It doesn't free the list
741
 
  itself.  It just should be used instead of text_tag_list_clear() which
742
 
  doesn't free the tags.
743
 
**************************************************************************/
744
 
void text_tag_list_clear_all(struct text_tag_list *tags)
745
 
{
746
 
  if (!tags) {
747
 
    return;
748
 
  }
749
 
 
750
 
  text_tag_list_iterate(tags, ptag) {
751
 
    text_tag_destroy(ptag);
752
 
  } text_tag_list_iterate_end;
753
 
  text_tag_list_clear(tags);
754
 
}
755
 
 
756
 
/**************************************************************************
757
 
  This function returns a new pointer to a text_tag_list which is similar
758
 
  to the 'tags' argument.
759
 
**************************************************************************/
760
 
struct text_tag_list *text_tag_list_dup(const struct text_tag_list *tags)
761
 
{
762
 
  struct text_tag_list *new_tags;
763
 
 
764
 
  if (!tags) {
765
 
    return NULL;
766
 
  }
767
 
 
768
 
  new_tags = text_tag_list_new();
769
 
  text_tag_list_iterate(tags, ptag) {
770
 
    struct text_tag *pnew_tag = fc_malloc(sizeof(struct text_tag));
771
 
 
772
 
    *pnew_tag = *ptag;
773
 
    text_tag_list_append(new_tags, pnew_tag);
774
 
  } text_tag_list_iterate_end;
775
 
 
776
 
  return new_tags;
777
 
}
778
 
 
779
 
/**************************************************************************
780
757
  Extract a sequence from a string.  Also, determine the type and the text
781
758
  tag type of the sequence.  Return 0 on error.
782
759
**************************************************************************/
798
775
  }
799
776
 
800
777
  /* Check sequence type. */
801
 
  for (read++; my_isspace(*read); read++);
 
778
  for (read++; fc_isspace(*read); read++);
802
779
 
803
780
  if (*read == SEQ_END) {
804
781
    *seq_type = ST_STOP;
805
782
    read++;
806
783
  } else {
807
 
    for (end--; my_isspace(*end); end--);
 
784
    for (end--; fc_isspace(*end); end--);
808
785
 
809
786
    if (*end == SEQ_END) {
810
787
      *seq_type = ST_SINGLE;
811
788
 
812
 
      for (end--; my_isspace(*end); end--);
 
789
      for (end--; fc_isspace(*end); end--);
813
790
    } else {
814
791
      *seq_type = ST_START;
815
792
    }
816
793
  }
817
794
 
818
 
  while (my_isspace(*read)) {
 
795
  while (fc_isspace(*read)) {
819
796
    read++;
820
797
  }
821
798
 
822
799
  /* Check the length of the type name. */
823
800
  for (name = read; name < stop; name++) {
824
 
    if (!my_isalpha(*name)) {
 
801
    if (!fc_isalpha(*name)) {
825
802
      break;
826
803
    }
827
804
  }
830
807
  *type = -1;
831
808
  for (i = 0; (name = text_tag_type_name(i)); i++) {
832
809
    name_len = strlen(name);
833
 
    if (name_len == type_len && 0 == mystrncasecmp(name, read, name_len)) {
 
810
    if (name_len == type_len && 0 == fc_strncasecmp(name, read, name_len)) {
834
811
      read += name_len;
835
812
      *type = i;
836
813
      break;
840
817
    /* Try with short names. */
841
818
    for (i = 0; (name = text_tag_type_short_name(i)); i++) {
842
819
      name_len = strlen(name);
843
 
      if (name_len == type_len && 0 == mystrncasecmp(name, read, name_len)) {
 
820
      if (name_len == type_len
 
821
          && 0 == fc_strncasecmp(name, read, name_len)) {
844
822
        read += name_len;
845
823
        *type = i;
846
824
        break;
851
829
    }
852
830
  }
853
831
 
854
 
  while (my_isspace(*read)) {
 
832
  while (fc_isspace(*read)) {
855
833
    read++;
856
834
  }
857
835
 
858
836
  if (end - read + 2 > 0) {
859
 
    mystrlcpy(buf, read, MIN(end - read + 2, len));
 
837
    fc_strlcpy(buf, read, MIN(end - read + 2, len));
860
838
  } else {
861
839
    buf[0] = '\0';
862
840
  }
869
847
**************************************************************************/
870
848
size_t featured_text_to_plain_text(const char *featured_text,
871
849
                                   char *plain_text, size_t plain_text_len,
872
 
                                   struct text_tag_list *tags)
 
850
                                   struct text_tag_list **tags)
873
851
{
874
852
  const char *read = featured_text;
875
853
  char *write = plain_text;
876
854
  size_t write_len = plain_text_len;
877
855
 
878
856
  if (tags) {
879
 
    text_tag_list_clear_all(tags);
 
857
    *tags = text_tag_list_new();
880
858
  }
881
859
 
882
860
  while (*read != '\0' && write_len > 1) {
899
877
 
900
878
            if (text_tag_init_from_sequence(ptag, type,
901
879
                                            write - plain_text, buf)) {
902
 
              text_tag_list_append(tags, ptag);
 
880
              text_tag_list_append(*tags, ptag);
903
881
            } else {
904
882
              text_tag_destroy(ptag);
905
 
              freelog(LOG_FEATURED_TEXT,
906
 
                      "Couldn't create a text tag with \"%s\".", buf);
 
883
              log_featured_text("Couldn't create a text tag with \"%s\".",
 
884
                                buf);
907
885
            }
908
886
          }
909
887
          break;
913
891
            struct text_tag *ptag = NULL;
914
892
 
915
893
            /* Look up on reversed order. */
916
 
            text_tag_list_rev_iterate(tags, piter) {
 
894
            text_tag_list_rev_iterate(*tags, piter) {
917
895
              if (piter->type == type
918
896
                  && piter->stop_offset == FT_OFFSET_UNSET) {
919
897
                ptag = piter;
924
902
            if (ptag) {
925
903
              ptag->stop_offset = write - plain_text;
926
904
            } else {
927
 
              freelog(LOG_FEATURED_TEXT, "Extra text tag end for \"%s\".",
928
 
                      text_tag_type_name(type));
 
905
              log_featured_text("Extra text tag end for \"%s\".",
 
906
                                text_tag_type_name(type));
929
907
            }
930
908
          }
931
909
          break;
936
914
 
937
915
            if (!text_tag_init_from_sequence(&tag, type,
938
916
                                             write - plain_text, buf)) {
939
 
              freelog(LOG_FEATURED_TEXT,
940
 
                      "Couldn't create a text tag with \"%s\".", buf);
 
917
              log_featured_text("Couldn't create a text tag with \"%s\".",
 
918
                                buf);
941
919
            } else {
942
920
              len = text_tag_replace_text(&tag, write, write_len);
943
921
              write += len;
948
926
 
949
927
                *ptag = tag;
950
928
                ptag->stop_offset = write - plain_text;
951
 
                text_tag_list_append(tags, ptag);
 
929
                text_tag_list_append(*tags, ptag);
952
930
              }
953
931
            }
954
932
          }
1000
978
      || start_offset > strlen(text_source)
1001
979
      || (stop_offset != FT_OFFSET_UNSET
1002
980
          && stop_offset < start_offset)) {
1003
 
    freelog(LOG_FEATURED_TEXT, "featured_text_apply_tag: invalid offsets.");
 
981
    log_featured_text("featured_text_apply_tag(): invalid offsets.");
1004
982
    return 0;
1005
983
  }
1006
984
 
1068
1046
{
1069
1047
  static char buf[MAX_LEN_LINK];
1070
1048
 
1071
 
  my_snprintf(buf, sizeof(buf), "%c%s tgt=\"%s\" id=%d name=\"%s\" %c%c",
 
1049
  fc_snprintf(buf, sizeof(buf), "%c%s tgt=\"%s\" id=%d name=\"%s\" %c%c",
1072
1050
              SEQ_START, text_tag_type_short_name(TTT_LINK),
1073
1051
              text_link_type_name(TLT_CITY), pcity->id,
1074
1052
              city_name(pcity), SEQ_END, SEQ_STOP);
1086
1064
  static char buf[MAX_LEN_LINK];
1087
1065
  const char *tag_name = text_tag_type_short_name(TTT_LINK);
1088
1066
 
1089
 
  my_snprintf(buf, sizeof(buf), "%c%s tgt=\"%s\" x=%d y=%d%c%s%c%c%s%c",
 
1067
  fc_snprintf(buf, sizeof(buf), "%c%s tgt=\"%s\" x=%d y=%d%c%s%c%c%s%c",
1090
1068
              SEQ_START, tag_name, text_link_type_name(TLT_TILE),
1091
1069
              TILE_XY(city_tile(pcity)), SEQ_STOP, city_name(pcity),
1092
1070
              SEQ_START, SEQ_END, tag_name, SEQ_STOP);
1102
1080
{
1103
1081
  static char buf[MAX_LEN_LINK];
1104
1082
 
1105
 
  my_snprintf(buf, sizeof(buf), "%c%s tgt=\"%s\" x=%d y=%d %c%c",
 
1083
  fc_snprintf(buf, sizeof(buf), "%c%s tgt=\"%s\" x=%d y=%d %c%c",
1106
1084
              SEQ_START, text_tag_type_short_name(TTT_LINK),
1107
1085
              text_link_type_name(TLT_TILE), TILE_XY(ptile),
1108
1086
              SEQ_END, SEQ_STOP);
1120
1098
 
1121
1099
  /* We use the rule name of the unit, it will be translated in every
1122
1100
   * local sides in the function text_tag_replace_text(). */
1123
 
  my_snprintf(buf, sizeof(buf), "%c%s tgt=\"%s\" id=%d name=\"%s\" %c%c",
 
1101
  fc_snprintf(buf, sizeof(buf), "%c%s tgt=\"%s\" id=%d name=\"%s\" %c%c",
1124
1102
              SEQ_START, text_tag_type_short_name(TTT_LINK),
1125
1103
              text_link_type_name(TLT_UNIT), punit->id,
1126
1104
              unit_rule_name(punit), SEQ_END, SEQ_STOP);
1138
1116
  static char buf[MAX_LEN_LINK];
1139
1117
  const char *tag_name = text_tag_type_short_name(TTT_LINK);
1140
1118
 
1141
 
  my_snprintf(buf, sizeof(buf), "%c%s tgt=\"%s\" x=%d y=%d%c%s%c%c%s%c",
 
1119
  fc_snprintf(buf, sizeof(buf), "%c%s tgt=\"%s\" x=%d y=%d%c%s%c%c%s%c",
1142
1120
              SEQ_START, tag_name, text_link_type_name(TLT_TILE),
1143
1121
              TILE_XY(unit_tile(punit)), SEQ_STOP,
1144
1122
              unit_name_translation(punit),