Opened 14 years ago

Last modified 8 years ago

#45 new task

Minimise usage of standard string functions

Reported by: takkaria Owned by:
Milestone: Ongoing Keywords: cleanup

Description (last modified by takkaria)

To fix:

  1. grep for sprintf(), strcat(), strcpy(), strncpy(), etc
  2. replace with Angband's own versions.

Change History (14)

comment:1 Changed 14 years ago by takkaria

Rough counts:

  • strcpy: 150
  • strcat: 26
  • strncpy: 17
  • sprintf: 265

comment:2 Changed 14 years ago by takkaria

[52dda4a] (SVN r11) fixes strcat().

strncpy() is just used by two main- files, so we can leave that.

comment:3 Changed 14 years ago by takkaria

  • Owner set to takkaria
  • Status changed from new to assigned

comment:4 Changed 14 years ago by takkaria

  • Milestone changed from 3.0.8 to 3.0.9

Moving to 3.0.9 for completion.

comment:5 Changed 14 years ago by andrewdoull

Shouldn't we use the OpenBSD strlcpy() and strlcat() instead of rolling our own as per the following white paper?

I don't know if a BSD-type license is compatible with Angband though.

comment:6 Changed 14 years ago by pmac

This is an excellent idea, so long as appropriate HAVE_STRLCPY is added to appropriate config files.
Also: there's no need to worry about licensing; the specifications are public, so just rename my_strcat, my_strcpy appropriately.

BTW: I've got this done, but it is all mixed up with the dirent stuff.

comment:7 Changed 14 years ago by takkaria

I have a patch that takes them down to:

  • strcpy(): 29 (in main-ros and main-win)
  • sprintf(): 73 (main-ros, main-crb, main-gtk, main-win, main-x11, main-xaw, and z-form)
  • strncat(): 0
  • strncpy(): 16 (main-crb, main-ros)

This has the nice side-effect of compiling without linker warnings on OpenBSD, which tells you off for using strcpy() and sprintf(). Will commit when SVN is back up.

comment:8 Changed 14 years ago by takkaria

  • Keywords cleanup added

comment:10 Changed 13 years ago by takkaria

  • Owner takkaria deleted
  • Status changed from assigned to new

comment:11 Changed 13 years ago by takkaria

Should we stop using sprintf() in strnfmt() and do it ourselves?

comment:12 Changed 13 years ago by anonymous

Taken care of in my local copy of main-gtk.c (which should eventually be in svn). A lot of the changes I made were in code that originally came from main-x11.c, so it shouldn't be too hard to get rid of them there, as well...

comment:13 Changed 10 years ago by magnate

  • Type changed from change to task

comment:14 Changed 9 years ago by magnate

  • Milestone changed from 4.0 to 3.5.0

These are all underlying or uncontroversial issues, unconnected with the experimental nature of v4 - therefore re-setting to V milestone.

comment:15 Changed 8 years ago by takkaria

  • Description modified (diff)
  • Milestone changed from 3.5.0 to Ongoing
Note: See TracTickets for help on using tickets.