aboutsummaryrefslogtreecommitdiff
path: root/comms/yagiuda
diff options
context:
space:
mode:
authorDiane Bruce <db@FreeBSD.org>2017-10-28 16:15:16 +0000
committerDiane Bruce <db@FreeBSD.org>2017-10-28 16:15:16 +0000
commit487752f07dea165bbf3f96dc30e67f4c2d024e2c (patch)
tree7aba7cef1279f8c33da6f73def65eb51eae107e6 /comms/yagiuda
parent6c52cfec3bf9239b35acaeb7098dae0cd7eb5c53 (diff)
downloadports-487752f07dea165bbf3f96dc30e67f4c2d024e2c.tar.gz
ports-487752f07dea165bbf3f96dc30e67f4c2d024e2c.zip
- @fjoe correctly pointed out one place where the newline needed to be
removed, I did miss that one. (It's directly used as a filename) The other places are do not cares. - It makes no sense to remove gets() without removing potentially just as bad scanf() calls and it's bad practice to use scanf anyway I'm paranoid with implementations of fgets() (Non FreeBSD to be clear) hence the use of -1 in the length argument of fgets(). - I'll see if upstream is willing to accept these diffs. Submitted by: Max Khon <fjoe@freebsd.org> Reported by: Max Khon <fjoe@freebsd.org>
Notes
Notes: svn path=/head/; revision=453062
Diffstat (limited to 'comms/yagiuda')
-rw-r--r--comms/yagiuda/Makefile1
-rw-r--r--comms/yagiuda/files/patch-src_dynamic.c41
-rw-r--r--comms/yagiuda/files/patch-src_input.c220
3 files changed, 254 insertions, 8 deletions
diff --git a/comms/yagiuda/Makefile b/comms/yagiuda/Makefile
index c4632f306902..2ad6af721144 100644
--- a/comms/yagiuda/Makefile
+++ b/comms/yagiuda/Makefile
@@ -3,6 +3,7 @@
PORTNAME= yagiuda
PORTVERSION= 1.19
+PORTREVISION= 1
CATEGORIES= comms hamradio
MASTER_SITES= http://www.g8wrb.org/yagi/ \
LOCAL/db
diff --git a/comms/yagiuda/files/patch-src_dynamic.c b/comms/yagiuda/files/patch-src_dynamic.c
new file mode 100644
index 000000000000..41cc7f8bbdd6
--- /dev/null
+++ b/comms/yagiuda/files/patch-src_dynamic.c
@@ -0,0 +1,41 @@
+--- src/dynamic.c.orig 2000-10-28 11:45:50 UTC
++++ src/dynamic.c
+@@ -13,7 +13,8 @@ void dynamic_changing_of_weights(int i,
+ char c, *str;
+ if(i%divisor==0)
+ {
+- str=string(0L,100L);
++#define MAXINPUTLINE 100L
++ str=string(0L,MAXINPUTLINE);
+ if((fopen("change","rt"))!=NULL)
+ {
+ system("rm change");
+@@ -23,24 +24,24 @@ void dynamic_changing_of_weights(int i,
+ {
+ case 'G':
+ printf("Enter new weight for gain -current weight=%f\n",weight->gain);
+- scanf("%s",str);
++ fgets(str, MAXINPUTLINE-1, stdin);
+ weight->gain=atof(str);
+ fflush(stdin);
+ break;
+
+ case 'F':
+ printf("Enter new weight for FB -current weight=%f\n",weight->fb);
+- gets(str);
++ fgets(str, MAXINPUTLINE-1, stdin);
+ weight->fb=atof(str);
+ break;
+
+ case 'P':
+ printf("Enter new weight for sidelobe -current weight=%f\n",weight->sidelobe);
+- gets(str);
++ fgets(str, MAXINPUTLINE-1, stdin);
+ weight->sidelobe=atof(str);
+ break;
+ } /* end of switch statement */
+ } /* end of if file exits/user hit keyboard */
+- free_string(str,0L,100L);
++ free_string(str,0L,MAXINPUTLINE);
+ } /* end of if divisor%10==0 */
+ } /* function */
diff --git a/comms/yagiuda/files/patch-src_input.c b/comms/yagiuda/files/patch-src_input.c
index 5797eda913c9..47d57e278394 100644
--- a/comms/yagiuda/files/patch-src_input.c
+++ b/comms/yagiuda/files/patch-src_input.c
@@ -1,26 +1,34 @@
--- src/input.c.orig 2005-07-10 09:16:31 UTC
+++ src/input.c
-@@ -16,7 +16,6 @@ manually!
+@@ -16,7 +16,7 @@ manually!
*/
#include <stdio.h>
-#include <malloc.h>
++#include <string.h>
#include <math.h>
#include "nrutil.h"
#include "yagi.h"
-@@ -32,8 +31,9 @@ int main(int argc, char **argv)
- char response, *filename, *notes, *type, data_entry;
+@@ -29,12 +29,14 @@ int main(int argc, char **argv)
+ double min_f, max_f, step_f, angular_step;
+ int elements, driven, i, fixed_diameter, boom, parasitic, c, hflg=0, errflg=0;
+ double scale_factor;
+- char response, *filename, *notes, *type, data_entry;
++ char response, *filename, *notes, *type, *str, data_entry;
FILE *fp;
- filename = string(0L, 1000L);
- notes = string(0L, 1000L);
-+#define MAXINPUTLINE 1000
+- type = string(0L, 1000L);
++#define MAXINPUTLINE 1000L
+ filename = string(0L, MAXINPUTLINE);
+ notes = string(0L, MAXINPUTLINE);
- type = string(0L, 1000L);
++ type = string(0L, MAXINPUTLINE);
++ str = string(0L, MAXINPUTLINE);
while ((c = getoptions(argc,argv,"h")) != -1)
-@@ -56,10 +56,10 @@ int main(int argc, char **argv)
+ switch (c)
+@@ -56,56 +58,65 @@ int main(int argc, char **argv)
printf("\nThis program asks for length, diameter and position of antenna elements then\n");
printf("writes them to a file you specify. Data is written in m (metres)\n \n");
printf("Enter any notes on this design (up to 400 characters): ");
@@ -28,10 +36,206 @@
- printf("Enter a filename to write data to ");
- gets(filename);
- printf("Enter the centre frequency in MHz ");
+- scanf("%lf", &frequency);
+ fgets(notes, MAXINPUTLINE-1, stdin);
++ notes[strcspn(notes, "\n")] = '\0';
+ printf("Enter a filename to write data to ");
+ fgets(filename, MAXINPUTLINE-1, stdin);
++ filename[strcspn(filename, "\n")] = '\0';
+ printf("Enter the centre frequency in MHz ");
- scanf("%lf", &frequency);
++ fgets(str, MAXINPUTLINE-1, stdin);
++ sscanf(str,"%lf", &frequency);
printf("Enter the minimum frequency in MHz ");
- scanf("%lf", &min_f);
+- scanf("%lf", &min_f);
++ fgets(str, MAXINPUTLINE-1, stdin);
++ sscanf(str,"%lf", &min_f);
+ printf("Enter the maximum frequency in MHz ");
+- scanf("%lf", &max_f);
++ fgets(str, MAXINPUTLINE-1, stdin);
++ sscanf(str,"%lf", &max_f);
+ printf("Enter the frequency steps in MHz ");
+- scanf("%lf", &step_f);
++ fgets(str, MAXINPUTLINE-1, stdin);
++ sscanf(str,"%lf", &step_f);
+ if(min_f > frequency)
+ nrerror("The minimum frequency has been set higher than the centre frequency");
+ if(max_f < frequency)
+ nrerror("The maximum frequency has been set lower than the centre frequency");
+ printf("\nData can be entered in imperial (inches) metric (mm) or wavelengths (lambda)\n");
+ printf("Please enter i (for imperial), m (for metric) or w (for wavelengths). ");
+- scanf("%c", &data_entry);
+- scanf("%c", &data_entry);
++ fgets(str, MAXINPUTLINE-1, stdin);
++ sscanf(str,"%c", &data_entry);
+ /* The file produced by this is always written in metres. */
+ if(data_entry=='i' || data_entry=='I')
+ {
+ scale_factor=39.37; /* inches in 1m */
+- type="\"\"";
++ strcpy(type,"\"\"");
+ }
+ else if(data_entry=='m' || data_entry=='m')
+ {
+ scale_factor=1000.0; /* mm in 1m */
+- type="mm";
++ strcpy(type,"mm");
+ }
+ else if(data_entry=='w' || data_entry=='w')
+ {
+ scale_factor=frequency/300; /* wavelegths in 1m */
+- type="lambda";
++ strcpy(type,"lambda");
+ }
+ else
+ exit(1);
+ printf("Enter the number of elements for the antenna ");
+- scanf("%d",&elements);
++ fgets(str, MAXINPUTLINE-1, stdin);
++ sscanf(str,"%d",&elements);
+ /* printf("Enter the number of driven elements ");
+- scanf("%d", &driven); */
++ fgets(str, MAXINPUTLINE-1, stdin);
++ sscanf(str,"%d", &driven); */
+ driven=1;
+ parasitic=elements-driven;
+ d=dmatrix(1L, (long) driven, 1L, 6L);
+ p=dmatrix(1L, (long) parasitic , 1L, 4L);
+ printf("Enter the angular step size in degrees for the gain to be plotted ");
+- scanf("%lf",&angular_step);
++ fgets(str, MAXINPUTLINE-1, stdin);
++ sscanf(str,"%lf",&angular_step);
+ /* printf("Are any of the elements tappered? ");
+- scanf("%c", &response);
+- scanf("%c", &response);
++ fgets(str, MAXINPUTLINE-1, stdin);
++ sscanf(str,"%c", &response);
+ if(response =='y' || response == 'Y')
+ {
+ tappered=TRUE;
+@@ -114,12 +125,13 @@ int main(int argc, char **argv)
+ }
+ */
+ printf("Are all the elements of the same diameter ? ");
+- scanf("%c",&response);
+- scanf("%c",&response);
++ fgets(str, MAXINPUTLINE-1, stdin);
++ sscanf(str,"%c",&response);
+ if(response=='Y' || response =='y')
+ {
+ printf("Enter the diameter of the elements (in %s) ", type);
+- scanf("%lf", &diameter);
++ fgets(str, MAXINPUTLINE-1, stdin);
++ sscanf(str,"%lf", &diameter);
+ fixed_diameter=TRUE;
+ }
+ else
+@@ -128,29 +140,35 @@ int main(int argc, char **argv)
+ for(i=1;i<=driven;++i)
+ {
+ printf("\n\nEnter location of the driven element in %s (wrt. reflector at x=0) ", type);
+- scanf("%lf", &d[i][X]);
++ fgets(str, MAXINPUTLINE-1, stdin);
++ sscanf(str,"%lf", &d[i][X]);
+ d[i][Y]=0;
+ if( boom != TRUE)
+ {
+ printf("Enter the y position of the driven element (in %s) ", type);
+- scanf("%lf", &d[i][Y]);
++ fgets(str, MAXINPUTLINE-1, stdin);
++ sscanf(str,"%lf", &d[i][Y]);
+ }
+ else
+ d[i][Y]=0.0;
+ printf("Enter length of the driven element (in %s) ", type);
+- scanf("%lf", &d[i][LENGTH]);
++ fgets(str, MAXINPUTLINE-1, stdin);
++ sscanf(str,"%lf", &d[i][LENGTH]);
+ if(fixed_diameter == TRUE)
+ d[i][DIAMETER]=diameter;
+ else
+ {
+ printf("Enter the diameter of the driven element (in %s) ", type);
+- scanf("%lf", &d[i][DIAMETER]);
++ fgets(str, MAXINPUTLINE-1, stdin);
++ sscanf(str,"%lf", &d[i][DIAMETER]);
+ }
+ /*
+ printf("Enter the voltage driving this element ");
+- scanf("%lf", &d[i][VOLTAGE_R]);
++ fgets(str, MAXINPUTLINE-1, stdin);
++ sscanf(str,"%lf", &d[i][VOLTAGE_R]);
+ printf("Enter the phase driving this element ");
+- scanf("%lf", &d[i][VOLTAGE_I]);
++ fgets(str, MAXINPUTLINE-1, stdin);
++ sscanf(str,"%lf", &d[i][VOLTAGE_I]);
+ */
+ d[i][VOLTAGE_R]=1.0;
+ d[i][VOLTAGE_I]=0.0;
+@@ -160,39 +178,46 @@ int main(int argc, char **argv)
+ if(i==1) /* The reflector */
+ {
+ printf("\nEnter length of the reflector (in %s) ", type);
+- scanf("%lf", &p[1][LENGTH]);
++ fgets(str, MAXINPUTLINE-1, stdin);
++ sscanf(str,"%lf", &p[1][LENGTH]);
+ if(boom != TRUE)
+ {
+ printf("\nEnter the y position of the reflector (in %s) ", type);
+- scanf("%lf", &p[i][Y]);
++ fgets(str, MAXINPUTLINE-1, stdin);
++ sscanf(str,"%lf", &p[i][Y]);
+ }
+ if(fixed_diameter == TRUE)
+ p[i][DIAMETER]=diameter;
+ else
+ {
+ printf("Enter the diameter of the reflector (in %s) ", type);
+- scanf("%lf", &p[i][DIAMETER]);
++ fgets(str, MAXINPUTLINE-1, stdin);
++ sscanf(str,"%lf", &p[i][DIAMETER]);
+ }
+ }
+ else /* a director */
+ {
+ printf("\n\nEnter location of director %d in %s (wrt. reflector at x=0.0) ", i-1, type);
+- scanf("%lf", &p[i][X]);
++ fgets(str, MAXINPUTLINE-1, stdin);
++ sscanf(str,"%lf", &p[i][X]);
+ if( boom != TRUE)
+ {
+ printf("Enter the y position of director %d (in %s) ", i-1, type);
+- scanf("%lf", &p[i][Y]);
++ fgets(str, MAXINPUTLINE-1, stdin);
++ sscanf(str,"%lf", &p[i][Y]);
+ }
+ else
+ p[i][Y]=0.0;
+ printf("Enter the length of director %d (in %s) ", i-1,type);
+- scanf("%lf", &p[i][LENGTH]);
++ fgets(str, MAXINPUTLINE-1, stdin);
++ sscanf(str,"%lf", &p[i][LENGTH]);
+ if(fixed_diameter == TRUE)
+ p[i][DIAMETER]=diameter;
+ else
+ {
+ printf("Enter the diameter of director %d (in %s) ", i-1, type);
+- scanf("%lf", &p[i][DIAMETER]);
++ fgets(str, MAXINPUTLINE-1, stdin);
++ sscanf(str,"%lf", &p[i][DIAMETER]);
+ }
+ }
+ }
+@@ -200,9 +225,10 @@ int main(int argc, char **argv)
+ fp=fopen(filename,"wt");
+ write_input_data_to_disk(fp, notes, frequency, min_f, max_f, step_f, elements , driven, parasitic, angular_step, d, p, scale_factor);
+ fclose(fp);
+- free_string(filename,0L, 1000L);
+- free_string(notes,0L, 1000L);
+- free_string(type,0L, 1000L);
++ free_string(filename,0L, MAXINPUTLINE);
++ free_string(notes,0L, MAXINPUTLINE);
++ free_string(type,0L, MAXINPUTLINE);
++ free_string(str,0L, MAXINPUTLINE);
+ free_dmatrix(d, 1L, (long) driven, 1L, 6L);
+ free_dmatrix(p, 1L, (long) parasitic , 1L, 4L);
+ exit(0);