Ticket #45 (new feature)

Opened 2 years ago

Last modified 1 year ago

Minimise usage of standard string functions

Reported by: takkaria Assigned to:
Milestone: 3.2.0 Version:
Keywords: cleanup Cc:

Description

To fix:

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

Attachments

Change History

03/25/07 09:11:33 changed by takkaria

Rough counts:

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

03/25/07 09:43:36 changed by takkaria

[11] fixes strcat().

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

03/26/07 11:38:43 changed by takkaria

  • owner set to takkaria.
  • status changed from new to assigned.

04/20/07 07:47:57 changed by takkaria

  • milestone changed from 3.0.8 to 3.0.9.

Moving to 3.0.9 for completion.

05/10/07 08:48:02 changed by andrewdoull

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

http://www.gratisoft.us/todd/papers/strlcpy.html

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

05/10/07 17:47:33 changed 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.

05/13/07 16:54:04 changed 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.

06/03/07 12:07:16 changed by takkaria

  • keywords set to cleanup.

07/07/07 15:16:21 changed by takkaria

  • owner deleted.
  • status changed from assigned to new.

07/14/07 16:31:55 changed by takkaria

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

08/27/07 02:43:49 changed 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...


Add/Change #45 (Minimise usage of standard string functions)