Dave Shield wrote:
> Note that there has been a problem with the last couple
> of releases (including the 5.4.1.preX tarballs), which may
> possibly result in the Workspace files having the wrong
> line endings.  This means that Visual Studio doesn't
> always recognise them as such.

There is simple program, maybe it will be useful.
See attachment...

                        Aleksandr Lomanov
// atoda.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <stdio.h>

#define MAX_SIZE        524288L
int main(int argc, char* argv[])
{
        char prev, *cp, buffer[MAX_SIZE];
        FILE *handle = NULL;
        long filesize;
        int change_f = 0;
        int fail_f = 0;

        if (argc == 1 || argc < 2) {
                printf(
                        "This program adds carriage return 0x0d before 0x0a one 
time.\n"
                        "Usage: atoda <filename.ext>\n"
                        );
                fail_f = 1;
                goto finish;
        }

        if ((handle = fopen(argv[1], "r+b")) == NULL) {
                printf("Cannot open file '%s'.\n", argv[1]);
                fail_f = 1;
                goto finish;
        }

        fseek(handle, 0L, SEEK_END);
        if(MAX_SIZE < ftell(handle)) {
                printf("File too big. Maximum size is %d bytes.\n", MAX_SIZE);
                fail_f = 1;
                goto finish;
        }

        cp = buffer;
        fseek(handle, 0L, SEEK_SET);

        while(!feof(handle)) *(cp++) = (char) fgetc(handle);
        filesize = cp - buffer;

        cp = buffer;
        fseek(handle, 0L, SEEK_SET);

        prev = *cp;
        while(--filesize > 0) {
                if(*cp == 0x0a && prev != 0x0d) {
                        fputc(0x0d, handle);
                        change_f = 1;
                }
                fputc(*cp, handle);
                prev = *cp++;
        }
        
finish:
        if(handle) fclose(handle);
        if(fail_f)
                printf("Failed.\n");
        else {
                if(change_f)
                        printf("Finished.\n");
                else
                        printf("No changes.\n");
        }

        return 0;
}
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Net-snmp-coders mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders

Reply via email to