Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
N
nettle
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Dmitry Baryshkov
nettle
Commits
024d5cde
Commit
024d5cde
authored
Oct 23, 2007
by
Niels Möller
Browse files
Options
Downloads
Patches
Plain Diff
Deleted the code for binary output.
Rev: nettle/examples/eratosthenes.c:1.3
parent
48c2100a
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
examples/eratosthenes.c
+7
-90
7 additions, 90 deletions
examples/eratosthenes.c
with
7 additions
and
90 deletions
examples/eratosthenes.c
+
7
−
90
View file @
024d5cde
...
...
@@ -58,7 +58,6 @@ usage(void)
" --primes-only Suppress output of differences.
\n
"
" --diff-only Supress output of primes.
\n
"
" --tabular Tabular output (default is one prime per line).
\n
"
" --binary Binary output.
\n
"
" --block SIZE Block size.
\n
"
);
}
...
...
@@ -185,14 +184,11 @@ struct output_info
{
int
output_2
;
enum
{
FORMAT_PRIMES
=
1
,
FORMAT_DIFF
=
2
,
FORMAT_TABULAR
=
4
,
FORMAT_BINARY
=
8
FORMAT_PRIMES
=
1
,
FORMAT_DIFF
=
2
,
FORMAT_TABULAR
=
4
}
format
;
unsigned
long
last
;
unsigned
column
;
/* For the binary output */
unsigned
size
;
};
static
void
...
...
@@ -201,79 +197,12 @@ output_init(struct output_info *info)
info
->
output_2
=
1
;
info
->
format
=
FORMAT_PRIMES
|
FORMAT_DIFF
;
info
->
last
=
0
;
info
->
size
=
1
;
}
static
void
output
(
struct
output_info
*
info
,
unsigned
long
p
)
{
if
(
info
->
format
&
FORMAT_BINARY
)
{
/* Overrides the other formats. */
unsigned
char
buf
[
4
];
unsigned
diff
=
(
p
-
info
->
last
)
/
2
;
switch
(
info
->
size
)
{
case
1
:
if
(
diff
<
0x100
)
{
putchar
(
diff
);
break
;
}
else
{
info
->
size
++
;
putchar
(
0
);
/* Fall through */
}
case
2
:
if
(
diff
<
0x10000
)
{
buf
[
0
]
=
diff
>>
8
;
buf
[
1
]
=
diff
&
0xff
;
putchar
(
buf
[
0
]);
putchar
(
buf
[
1
]);
break
;
}
else
{
info
->
size
++
;
putchar
(
0
);
putchar
(
0
);
/* Fall through */
}
case
3
:
if
(
diff
<
0x1000000
)
{
buf
[
0
]
=
diff
>>
16
;
buf
[
1
]
=
(
diff
>>
8
)
&
0xff
;
buf
[
2
]
=
diff
&
0xff
;
putchar
(
buf
[
0
]);
putchar
(
buf
[
1
]);
putchar
(
buf
[
2
]);
break
;
}
else
{
info
->
size
++
;
putchar
(
0
);
putchar
(
0
);
putchar
(
0
);
/* Fall through */
}
case
4
:
buf
[
0
]
=
diff
>>
24
;
buf
[
1
]
=
(
diff
>>
16
)
&
0xff
;
buf
[
2
]
=
(
diff
>>
8
)
&
0xff
;
buf
[
3
]
=
diff
&
0xff
;
putchar
(
buf
[
0
]);
putchar
(
buf
[
1
]);
putchar
(
buf
[
2
]);
putchar
(
buf
[
3
]);
break
;
}
}
else
if
(
info
->
format
&
(
FORMAT_PRIMES
|
FORMAT_DIFF
))
if
(
info
->
format
&
(
FORMAT_PRIMES
|
FORMAT_DIFF
))
{
if
(
info
->
format
&
FORMAT_PRIMES
)
printf
(
"%ld"
,
p
);
...
...
@@ -300,13 +229,6 @@ output(struct output_info *info, unsigned long p)
static
void
output_first
(
struct
output_info
*
info
)
{
if
(
info
->
format
&
FORMAT_BINARY
)
{
/* Omit 2, and start with 1, so that differences are odd. */
info
->
last
=
1
;
}
else
{
info
->
column
=
0
;
if
(
info
->
output_2
)
...
...
@@ -314,7 +236,6 @@ output_first(struct output_info *info)
info
->
last
=
2
;
}
}
int
main
(
int
argc
,
char
**
argv
)
...
...
@@ -333,7 +254,7 @@ main (int argc, char **argv)
int
quiet
;
int
c
;
enum
{
FLAG_ODD
=
-
100
,
FLAG_PRIME
,
FLAG_DIFF
,
FLAG_TABULAR
,
FLAG_BINARY
,
enum
{
FLAG_ODD
=
-
100
,
FLAG_PRIME
,
FLAG_DIFF
,
FLAG_TABULAR
,
FLAG_QUIET
,
FLAG_BLOCK
};
static
const
struct
option
options
[]
=
...
...
@@ -345,7 +266,6 @@ main (int argc, char **argv)
{
"prime-only"
,
no_argument
,
NULL
,
FLAG_PRIME
},
{
"diff-only"
,
no_argument
,
NULL
,
FLAG_DIFF
},
{
"tabular"
,
no_argument
,
NULL
,
FLAG_TABULAR
},
{
"binary"
,
no_argument
,
NULL
,
FLAG_BINARY
},
{
"block"
,
required_argument
,
NULL
,
FLAG_BLOCK
},
{
NULL
,
0
,
NULL
,
0
}
};
...
...
@@ -373,9 +293,6 @@ main (int argc, char **argv)
case
FLAG_TABULAR
:
info
.
format
|=
FORMAT_TABULAR
;
break
;
case
FLAG_BINARY
:
info
.
format
|=
FORMAT_BINARY
;
break
;
case
FLAG_QUIET
:
quiet
=
1
;
break
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment