patch-m_c 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. $OpenBSD: patch-m_c,v 1.2 2017/05/07 17:46:24 espie Exp $
  2. Index: m.c
  3. --- m.c.orig
  4. +++ m.c
  5. @@ -147,23 +147,24 @@ char *get_name(void)
  6. char *name;
  7. char *endchar;
  8. - if((name = (char *)getenv("NEWNAME")) == NULL)
  9. - if((name = (char *)getenv("NAME")) == NULL)
  10. - if((name = (char *)getenv("FULLNAME")) == NULL)
  11. - if((name = (char *)getenv("USER")) == NULL)
  12. - if((name = (char *)getenv("LOGNAME")) == NULL)
  13. + if((name = getenv("NEWNAME")) == NULL)
  14. + if((name = getenv("NAME")) == NULL)
  15. + if((name = getenv("FULLNAME")) == NULL)
  16. + if((name = getenv("USER")) == NULL)
  17. + if((name = getenv("LOGNAME")) == NULL)
  18. #define ASKNAME /* Marina */
  19. #ifdef ASKNAME /* M001 */
  20. {
  21. - name = (char *)malloc(80);
  22. + name = malloc(80);
  23. if (name == NULL) {
  24. printf("malloc error\n"); /* Replace with Err* */
  25. exit(1);
  26. }
  27. printf("Name? "); fflush(stdout);
  28. fgets(name,80,stdin); /* get rid of gets Marina*/
  29. - endchar=strchr(name,'\0');
  30. - endchar='\0';
  31. + endchar=strchr(name,'\n');
  32. + if (endchar)
  33. + *endchar='\0';
  34. if (name[0] == '\0')
  35. name = "noname";
  36. }
  37. @@ -181,9 +182,9 @@ char *get_keys()
  38. {
  39. char *keys = NULL;
  40. if( ! keys ) {
  41. - if((keys = (char *)getenv("NEWKEYS")) == NULL)
  42. + if((keys = getenv("NEWKEYS")) == NULL)
  43. {
  44. - keys = (char *)malloc(5);
  45. + keys = malloc(5);
  46. strcpy(keys,"kjhl");
  47. }
  48. }