[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: application patch



On Tue, 29 Mar 2005 10:34:13 +0200
tnemeth@free.fr wrote:

> Selon messmate <messmate@free.fr>:
> 
> | Bonjour,
> 
>     Bonjour.
> 
> 
> | cela fait une éternité que j'ai encore appliqué un patch.
> | Le apt-get nous rend bebête, non ?
> 
>     Non.
> 
> 
> | J'ai là un texte en clair que je dois appliquer en tant que patch à
> | mon postfix 2.2.
> | Quelqu'un se souviens comment faire ?
> 
>     Est-ce que "lire la page de man de patch" te dit quelquechose ?

OUI...

>     patch -pX < fichier-patch.diff
> 
>     Avec X == le niveau de patch (généralement 0).
> 
> Thomas.
> 
Voilà:
patch -p0 cleanup_message.c cleanup_message.diff
patching file cleanup_message.c
Hunk #1 FAILED at 296.
Hunk #2 succeeded at 307 with fuzz 1 (offset -2 lines).
Hunk #3 FAILED at 321.
Hunk #4 FAILED at 339.
Hunk #5 FAILED at 364.
Hunk #6 FAILED at 392.
Hunk #7 FAILED at 400.
Hunk #8 FAILED at 455.
Hunk #9 FAILED at 670.
8 out of 9 hunks FAILED -- saving rejects to file cleanup_message.c.rej

Et ceci est le reject:
***************
*** 296,303 ****
  
  /* cleanup_act - act upon a header/body match */
  
! static int cleanup_act(CLEANUP_STATE *state, char *context, const char *buf,
!                  const char *value, const char *map_class)
  {
      const char *optional_text = value + strcspn(value, " \t");
      int     command_len = optional_text - value;
--- 296,304 ----
  
  /* cleanup_act - act upon a header/body match */
  
! static const char *cleanup_act(CLEANUP_STATE *state, char *context,
!                   const char *buf, const char *value,
!                   const char *map_class)
  {
      const char *optional_text = value + strcspn(value, " \t");
      int     command_len = optional_text - value;
***************
*** 321,331 ****
   state->errs |= CLEANUP_STAT_CONT;
   state->flags &= ~CLEANUP_FLAG_FILTER;
   cleanup_act_log(state, "reject", context, buf, state->reason);
!  return (CLEANUP_ACT_KEEP);
      }
      if (STREQUAL(value, "WARN", command_len)) {
   cleanup_act_log(state, "warning", context, buf, optional_text);
!  return (CLEANUP_ACT_KEEP);
      }
      if (STREQUAL(value, "FILTER", command_len)) {
   if (*optional_text == 0) {
--- 321,331 ----
   state->errs |= CLEANUP_STAT_CONT;
   state->flags &= ~CLEANUP_FLAG_FILTER;
   cleanup_act_log(state, "reject", context, buf, state->reason);
!  return (buf);
      }
      if (STREQUAL(value, "WARN", command_len)) {
   cleanup_act_log(state, "warning", context, buf, optional_text);
!  return (buf);
      }
      if (STREQUAL(value, "FILTER", command_len)) {
   if (*optional_text == 0) {
***************
*** 339,356 ****
       state->filter = mystrdup(optional_text);
       cleanup_act_log(state, "filter", context, buf, optional_text);
   }
!  return (CLEANUP_ACT_KEEP);
      }
      if (STREQUAL(value, "DISCARD", command_len)) {
   cleanup_act_log(state, "discard", context, buf, optional_text);
   state->flags |= CLEANUP_FLAG_DISCARD;
   state->flags &= ~CLEANUP_FLAG_FILTER;
!  return (CLEANUP_ACT_KEEP);
      }
      if (STREQUAL(value, "HOLD", command_len)) {
   cleanup_act_log(state, "hold", context, buf, optional_text);
   state->flags |= CLEANUP_FLAG_HOLD;
!  return (CLEANUP_ACT_KEEP);
      }
      if (STREQUAL(value, "PREPEND", command_len)) {
   if (*optional_text == 0) {
--- 339,356 ----
       state->filter = mystrdup(optional_text);
       cleanup_act_log(state, "filter", context, buf, optional_text);
   }
!  return (buf);
      }
      if (STREQUAL(value, "DISCARD", command_len)) {
   cleanup_act_log(state, "discard", context, buf, optional_text);
   state->flags |= CLEANUP_FLAG_DISCARD;
   state->flags &= ~CLEANUP_FLAG_FILTER;
!  return (buf);
      }
      if (STREQUAL(value, "HOLD", command_len)) {
   cleanup_act_log(state, "hold", context, buf, optional_text);
   state->flags |= CLEANUP_FLAG_HOLD;
!  return (buf);
      }
      if (STREQUAL(value, "PREPEND", command_len)) {
   if (*optional_text == 0) {
***************
*** 364,391 ****
       cleanup_act_log(state, "prepend", context, buf, optional_text);
       cleanup_out_string(state, REC_TYPE_NORM, optional_text);
   }
!  return (CLEANUP_ACT_KEEP);
      }
      if (STREQUAL(value, "REPLACE", command_len)) {
   if (*optional_text == 0) {
       msg_warn("REPLACE action without text in %s map", map_class);
!      return (CLEANUP_ACT_KEEP);
!  } else if (strcmp(context, CLEANUP_ACT_CTXT_HEADER) == 0) {
!      if (!is_header(optional_text)) {
!   msg_warn("bad REPLACE header text \"%s\" in %s map, "
!     "need \"headername: headervalue\"",
!     optional_text, map_class);
!   return (CLEANUP_ACT_KEEP);
!      }
!      /* XXX Impedance mismatch. */
!      bp = vstring_strcpy(vstring_alloc(100), optional_text);
!      cleanup_out_header(state, bp);
!      vstring_free(bp);
   } else {
!      cleanup_out_string(state, REC_TYPE_NORM, optional_text);
   }
-  cleanup_act_log(state, "replace", context, buf, optional_text);
-  return (CLEANUP_ACT_DROP);
      }
      if (STREQUAL(value, "REDIRECT", command_len)) {
   if (strchr(optional_text, '@') == 0) {
--- 364,385 ----
       cleanup_act_log(state, "prepend", context, buf, optional_text);
       cleanup_out_string(state, REC_TYPE_NORM, optional_text);
   }
!  return (buf);
      }
      if (STREQUAL(value, "REPLACE", command_len)) {
   if (*optional_text == 0) {
       msg_warn("REPLACE action without text in %s map", map_class);
!      return (buf);
!  } else if (strcmp(context, CLEANUP_ACT_CTXT_HEADER) == 0
!      && !is_header(optional_text)) {
!      msg_warn("bad REPLACE header text \"%s\" in %s map, "
!        "need \"headername: headervalue\"",
!        optional_text, map_class);
!      return (buf);
   } else {
!      cleanup_act_log(state, "replace", context, buf, optional_text);
!      return (mystrdup(optional_text));
   }
      }
      if (STREQUAL(value, "REDIRECT", command_len)) {
   if (strchr(optional_text, '@') == 0) {
***************
*** 398,404 ****
       cleanup_act_log(state, "redirect", context, buf, optional_text);
       state->flags &= ~CLEANUP_FLAG_FILTER;
   }
!  return (CLEANUP_ACT_KEEP);
      }
      /* Allow and ignore optional text after the action. */
  
--- 392,398 ----
       cleanup_act_log(state, "redirect", context, buf, optional_text);
       state->flags &= ~CLEANUP_FLAG_FILTER;
   }
!  return (buf);
      }
      /* Allow and ignore optional text after the action. */
  
***************
*** 406,418 ****
   return (CLEANUP_ACT_DROP);
  
      if (STREQUAL(value, "DUNNO", command_len)) /* preferred */
!  return (CLEANUP_ACT_KEEP);
  
      if (STREQUAL(value, "OK", command_len)) /* compat */
!  return (CLEANUP_ACT_KEEP);
  
      msg_warn("unknown command in %s map: %s", map_class, value);
!     return (CLEANUP_ACT_KEEP);
  }
  
  /* cleanup_header_callback - process one complete header line */
--- 400,412 ----
   return (CLEANUP_ACT_DROP);
  
      if (STREQUAL(value, "DUNNO", command_len)) /* preferred */
!  return (buf);
  
      if (STREQUAL(value, "OK", command_len)) /* compat */
!  return (buf);
  
      msg_warn("unknown command in %s map: %s", map_class, value);
!     return (buf);
  }
  
  /* cleanup_header_callback - process one complete header line */
***************
*** 461,470 ****
   const char *value;
  
   if ((value = maps_find(checks, header, 0)) != 0) {
!      if (cleanup_act(state, CLEANUP_ACT_CTXT_HEADER,
!        header, value, map_class)
!   == CLEANUP_ACT_DROP)
    return;
   }
      }
  
--- 455,470 ----
   const char *value;
  
   if ((value = maps_find(checks, header, 0)) != 0) {
!      const char *result;
! 
!      if ((result = cleanup_act(state, CLEANUP_ACT_CTXT_HEADER,
!           header, value, map_class))
!   == CLEANUP_ACT_DROP) {
    return;
+      } else if (result != header) {
+   vstring_strcpy(header_buf, result);
+   myfree((char *) result);
+      }
   }
      }
  
***************
*** 670,679 ****
   const char *value;
  
   if ((value = maps_find(cleanup_body_checks, buf, 0)) != 0) {
!      if (cleanup_act(state, CLEANUP_ACT_CTXT_BODY,
!        buf, value, VAR_BODY_CHECKS)
!   == CLEANUP_ACT_DROP)
    return;
   }
      }
      cleanup_out(state, type, buf, len);
--- 670,686 ----
   const char *value;
  
   if ((value = maps_find(cleanup_body_checks, buf, 0)) != 0) {
!      const char *result;
! 
!      if ((result = cleanup_act(state, CLEANUP_ACT_CTXT_BODY,
!           buf, value, VAR_BODY_CHECKS))
!   == CLEANUP_ACT_DROP) {
!   return;
!      } else if (result != buf) {
!   cleanup_out(state, type, result, strlen(result));
!   myfree((char *) result);
    return;
+      }
   }
      }
      cleanup_out(state, type, buf, len);

mess-mate



Reply to: