home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / lang / c / 18666 < prev    next >
Encoding:
Internet Message Format  |  1992-12-21  |  3.3 KB

  1. Path: sparky!uunet!spool.mu.edu!agate!usenet.ins.cwru.edu!ukma!cs.widener.edu!dsinc!ub!csn!evolving.com!jww
  2. From: jww@evolving.com (John W. Woolley)
  3. Newsgroups: comp.lang.c
  4. Subject: SCCS eats good code -- help requested
  5. Message-ID: <1992Dec18.215413.65833@evolving.com>
  6. Date: 18 Dec 92 21:54:13 GMT
  7. Organization: Evolving Systems, Inc.
  8. Lines: 72
  9. X-Newsreader: Tin 1.1 PL4
  10.  
  11.  
  12. The other day I found what may qualify as the odd bug of the week.
  13. I'd be happy for any suggestions as to what to do about this.  Email
  14. me, please.
  15.  
  16. Evolving Systems recently began using a new source control system,
  17. CMVC, which as I understand it is a wrapper around SCCS.  The new
  18. source control system interacted with our code in an unintended way.
  19.  
  20. We had a chunk of source so:
  21.  
  22.   if (strftime(time_str, 64, "%w%H%M%S", time_struct) != 7)
  23.           ret_value = FAILURE;
  24.  
  25. Nice normal ANSI C.  But SCCS had spotted the string %H% in the
  26. above bit of code, and had done its replacement thing so:
  27.  
  28.   if (strftime(time_str, 64, "%w12/14/92M%S", time_struct) != 7)
  29.           ret_value = FAILURE;
  30.  
  31. which caused strftime to yield results differing somewhat from those
  32. intended.
  33.  
  34. (Admire for a moment the potential subtlety of this bug.  A customer
  35.  phones the help desk, unhappy that the code doesn't work.  You get
  36.  the IR, and try to reproduce his complaint; he's right, it fails.
  37.  So you check out the offending module, looking for suspicious code.
  38.  You see no bug, for the simple and sufficient reason that you,
  39.  naturally enough, checked the code out for edit, and the bug isn't
  40.  there in a writeable version.  You maybe tweak a comment here and
  41.  there.  You recompile.  You run the program -- everything goes fine.
  42.  Bug fixed.  You check the source back in and tell your boss that
  43.  everything's cool.
  44.  
  45.  But, the moment it the module gets checked out in the Golden Area
  46.  for a remake, BAM, bug time again.  Your boss calls you.  Your boss
  47.  threatens you.  You are unhappy.
  48.  
  49.  This is a new and wonderful thing -- a bug that only exists in code
  50.  that has been debugged, never in code you're trying to debug.)
  51.  
  52. One bit of good news is that printf and scanf have no upper-case
  53. conversion specifiers except E, G, and X; and one of those, X, is
  54. not mucked with by SCCS.  So only %E% and %G% might cause problems
  55. with those functions.  But strftime's specifiers have lots of overlap
  56. with SCCS's magic strings.
  57.  
  58. You can keep SCCS from doing the substitutions by calling its
  59. "get" command with a "-k" parameter, but that short-circuits all
  60. substitutions, even benign or beneficial ones; and we need those.
  61. You can keep it from happening in your code by breaking up the
  62. specifier strings thus:
  63.  
  64.   if (strftime(time_str, 64, "%w" "%H" "%M" "%S", time_struct) != 7)
  65.           ret_value = FAILURE;
  66.  
  67. or thus:
  68.  
  69.   if (strftime(time_str, 64, "%w\%H\%M\%S", time_struct) != 7)
  70.           ret_value = FAILURE;
  71.  
  72. but that's a really ugly kind of kluge, and one that's almost certain
  73. to be undone by the first eager-fingered editor through the source
  74. code who doesn't know why you did it.  (Oh, comments?  Well, yeah,
  75. they might help, but let's be real ...)  And, really, you shouldn't
  76. have to mess with source code to keep the source control system from
  77. messing you up.
  78.  
  79. So does anyone know anything good we can do about this?  We can't be
  80. the first site ever to struggle with format strings and SCCS.
  81.  
  82. -- John Woolley (jww@evolving.com)
  83.