migration_50_51.txt 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. Rules to migrate GRASS 5.0 modules into GRASS 5.7
  2. Date: 2003-09-11
  3. While implementing GRASS 5.7 a major cleanup of GRASS modules
  4. has to be done. The following rules shall help the programmer
  5. to migrate a 5.0 module into the 5.7 environment.
  6. 1. Add GPL statement
  7. 2. Programming details:
  8. o String buffer length:
  9. - to be identical for all modules
  10. o consistent return types. Situation in 5.0:
  11. The majority of functions return 0 on error and 1 on success, but there
  12. are many which return 0 on success and a negative value on failure.
  13. Proposal for 5.7? see below
  14. o Copying input parameters into a buffer, i.e.:
  15. strcpy (name, option.input->answer);
  16. strcpy (result, option.output->answer);
  17. is usually unnecessary. Furthermore, it's something which should be
  18. discouraged, due to the usual problems with fixed-size buffers.
  19. o Pre-formatting error/warning messages, e.g.:
  20. if (mapset == NULL)
  21. {
  22. char buf[200];
  23. sprintf (buf, "cell file [%s] not found", name);
  24. G_fatal_error (buf);
  25. }
  26. is unnecessary, as G_fatal_error() and G_warning() already do this,
  27. e.g.
  28. if (!mapset)
  29. G_fatal_error("cell file [%s] not found", name);
  30. o Ideally, all abnormal exits would be via G_fatal_error(), rather
  31. than calling exit() directly.
  32. o The value passed to exit() should be non-negative. exit(-1) is just
  33. a confusing way of writing exit(255).
  34. o C++ style comments are forbidden for portability reasons:
  35. use /* comment */ but NOT //comment
  36. 3. Style of file: We can reach pretty indenting through:
  37. indent -i4 -npsl -di0 -br -nce -d0 -cli0 -npcs -nfc1 FILE.c
  38. This should be done before uploading.
  39. ... to be extended...