diff -u hello.c hello_new.c > hello.patch
Transcript
diff -u hello.c hello_new.c > hello.patch
ERRORI
credits:
http://www.viva64.com/en/a/0079/#ID0
WOLFENSTEIN 3D
WOLFENSTEIN 3D
void CG_RegisterItemVisuals( int itemNum ) {
...
itemInfo_t *itemInfo;
...
memset( itemInfo, 0, sizeof( &itemInfo ) );
...
}
VIRTUALDUB
VIRTUALDUB
struct ConvoluteFilterData {
long m[9];
long bias;
void *dyna_func;
DWORD dyna_size;
DWORD dyna_old_protect;
BOOL fClip;
};
static unsigned long __fastcall do_conv(
unsigned long *data,
const ConvoluteFilterData *cfd,
long sflags, long pit)
{
long rt0=cfd->m[9], gt0=cfd->m[9], bt0=cfd->m[9];
...
}
NOTEPAD++
NOTEPAD ++
#define CONT_MAP_MAX 50
int _iContMap[CONT_MAP_MAX];
...
DockingManager::DockingManager()
{
...
memset(_iContMap, -1, CONT_MAP_MAX);
...
}
MIRANDA IM
MIRANDA IM
short ezxml_internal_dtd(ezxml_root_t root,
char *s, size_t len)
{
...
while (*(n = ++s + strspn(s, EZXML_WS)) && *n != '>') {
...
}
CHROMIUM PROJECT
CHROMIUM
#define FILE_ATTRIBUTE_DIRECTORY 0x00000010
bool GetPlatformFileInfo(PlatformFile file, PlatformFileInfo*
info) {
...
info->is_directory =
file_info.dwFileAttributes &
FILE_ATTRIBUTE_DIRECTORY != 0;
...
}
G3D
G3D
class Matrix3 {
...
inline float* operator[] (int iRow) {
...
};
void AnyVal::serialize(G3D::TextOutput& t) const {
...
const Matrix3& m = *(Matrix3*)m_value;
...
t.printf("%10.5f, %10.5f, %10.5f,\n
%10.5f, %10.5f, %10.5f,\n
%10.5f, %10.5f, %10.5f)",
m[0, 0], m[0, 1], m[0, 2],
m[1, 0], m[1, 1], m[1, 2],
m[2, 0], m[2, 1], m[2, 2]);
...
}
DIFF
hello.c
hello_new.c
#include <stdio.h>
#include <stdio.h>
int main() {
printf("Hello World\n");
}
int main(int argc, char *argv[])
{
printf("Hello World\n");
return 0;
}
• diff -u hello.c hello_new.c > hello.patch
• Applicabile anche a directory (opzioni –Naur)
DIFF FILE
--- hello.c
2014-10-07 18:17:49.000000000 +0530
+++ hello_new.c
2014-10-07 18:17:54.000000000 +0530
@@ -1,5 +1,6 @@
#include <stdio.h>
-int main() {
+int main(int argc, char *argv[]) {
printf("Hello World\n");
+
}
return 0;
PATCH
$ patch < hello.patch
patching file hello.c
oppure
patch [options] originalfile patchfile
PATCH
Nei diff file possono essere presenti dei percorsi relativi
(ad es. /home/tuonome/hello.c )
Potremmo volere ignorarli: esegui patch su hello.c in
directory attuale
patch -p3 < /root/tuapatch.patch
-p3 tells the patch command to skip 3 leading slashes from the
filenames present in the patch file. In our case, the filename in patch
file is “/usr/src/openvpn-2.3.2/aclocal.m4″, since you have given “-p3″,
3 leading slashes, i.e. until /usr/src/ is ignored.
PATCH
# testa la patch senza applicarla
patch --dry-run < hello.patch
#fa reverse della patch
patch -R < hello.patch
ESERCITAZIONE
trovare e correggere gli errori
http://tinyurl.com/hrcbhhx